当前位置:网站首页>8VC Venture Cup 2017 - Elimination Round D. PolandBall and Polygon
8VC Venture Cup 2017 - Elimination Round D. PolandBall and Polygon
2022-06-28 05:08:00 【不吃土司边】
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define eps 1e-2
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;
#define int long long
const int N = 1e6+2;
const int INF = 1<<30;
const int mod = 1e9+7;
int n,k;
struct BIT{
int n,c[N];
void init(int _n){
n=_n;for(int i=1;i<=n;++i) c[i]=0;}
int Lowbit(int x){
return x&(-x); }
int get_sum(int k){
int ans=c[k];while((k-=Lowbit(k))>0) ans+=c[k];return ans;}
void add(int t,int v){
c[t]+=v;while((t+=Lowbit(t))<=n) c[t]+=v;}
}bit1;
int get(int l,int r){
return bit1.get_sum(r)-bit1.get_sum(l-1);
}
void solve(){
scanf("%lld%lld",&n,&k);
bit1.init(N-1);
int st=1,ed=1+k,ans=1;
if(k>n/2) k=n-k;
for(int i=1;i<=n;i++){
ed=(st+k-1)%n+1;
// cout<<st<<" "<<ed<<endl;
if(st>ed){
ans+=1+get(1,ed-1)+get(st+1,n);
}else{
ans+=1+get(st+1,ed-1);
}
bit1.add(st,1);
bit1.add(ed,1);
st=ed;
cout<<ans<<" ";
}cout<<endl;
return;
}
int32_t main()
{
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
// ios::sync_with_stdio(false);
int t = 1;
//scanf("%d",&t);
while(t--){
// printf("Case %d: ",cas++);
solve();
}
return 0;
}
边栏推荐
- 学习太极创客 — MQTT 第二章(四)ESP8266 保留消息应用
- BioVendor sRAGE Elisa试剂盒化学性质和技术研究
- 2022烟花爆竹经营单位安全管理人员特种作业证考试题库及模拟考试
- Cgo+gsoap+onvif learning summary: 8. Summary of arm platform cross compilation operation and common problems
- 乔布斯在斯坦福大学的演讲稿——Follow your heart
- 深度强化学习笔记
- 2022年G3锅炉水处理复训题库模拟考试平台操作
- Feign通过自定义注解实现路径的转义
- Carboxylic acid study: lumiprobe sulfoacyanine 7 dicarboxylic acid
- 无线传感器网络学习笔记(一)
猜你喜欢

IP datagram sending and forwarding process

学习太极创客 — MQTT 第二章(四)ESP8266 保留消息应用

Extjs图书管理系统源码 智能化图书管理系统源码

Mask's miserable and inspirational childhood, who is introverted by campus violence

别卷!如何高质量地复现一篇论文?

Audio and video technology development weekly

openssl客户端编程:一个不起眼的函数导致的SSL会话失败问题

2022 safety officer-b certificate examination question bank and answers

Excel将一行的内容进行复制时,列与列之间是用制表符“\t”进行分隔的

Where does the storm go? Whose pot is the weather forecast wrong?
随机推荐
Pcr/qpcr research: lumiprobe dsgreen is used for real-time PCR
Hundreds of lines of code to implement a script interpreter
JS text box loses focus to modify width text and symbols
BioVendor sRAGE Elisa试剂盒化学性质和技术研究
使用class toplevel的messagebox时,窗口弹出问题。
Learning Tai Chi Maker - mqtt Chapter II (VI) mqtt wills
Voltage mode and current mode control of switching power supply
Project practice! Teach you JMeter performance test hand in hand
机器人学DH参数及利用matlab符号运算推导
CpG solid support research: lumiprobe general CpG type II
Severe tire damage: the first rock band in the world to broadcast live on the Internet
判断对象中是否存在某一个属性
Leetcode 88: merge two ordered arrays
别卷!如何高质量地复现一篇论文?
Learning Tai Chi Maker - mqtt Chapter 2 (V) heartbeat mechanism
Dart学习——函数、类
JS 文本框失去焦点修改全半角文字和符号
quartus 复制IP核
Interview: what are the similarities and differences between abstract classes and interfaces?
Dart learning - functions, classes