当前位置:网站首页>8VC Venture Cup 2017 - Elimination Round D. PolandBall and Polygon
8VC Venture Cup 2017 - Elimination Round D. PolandBall and Polygon
2022-06-28 05:19:00 【No toast】
#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;
}
边栏推荐
猜你喜欢
![[Verilog quick start of Niuke online question brushing series] ~ one out of four multiplexer](/img/1f/becda82f3136678c58dd8ed7bec8fe.png)
[Verilog quick start of Niuke online question brushing series] ~ one out of four multiplexer

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

Keil C51的Data Overlaying机制导致的函数重入问题

改性三磷酸盐研究:Lumiprobe氨基-11-ddUTP

JS text box loses focus to modify width text and symbols

【牛客网刷题系列 之 Verilog快速入门】~ 四选一多路器

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

The heading angle of sliceplane is the same as that of math Corresponding transformation relation of atan2 (y, x)

Lumiprobe细胞成像分析:PKH26 细胞膜标记试剂盒

2022年最新辽宁建筑八大员(标准员)考试试题及答案
随机推荐
Organize the online cake mall project
BioVendor sRAGE抗体解决方案
2022西式面点师(高级)考试试题模拟考试平台操作
Simple usage of GSAP
如何学习可编程逻辑控制器(PLC)?
Wireless sensor network learning notes (I)
JS 文本框失去焦点修改全半角文字和符号
[leetcode] 12. Integer to Roman numeral
SlicePlane的Heading角度与Math.atan2(y,x)的对应转换关系
Latest Windows version 5.0.14 of redis
2022年全国最新消防设施操作员(初级消防设施操作员)模拟题及答案
cgo+gSoap+onvif学习总结:8、arm平台交叉编译运行及常见问题总结
通过例子学习Rust
Assembly common instructions
程序员坐牢了,会被安排去写代码吗?
Pcr/qpcr research: lumiprobe dsgreen is used for real-time PCR
学习太极创客 — MQTT 第二章(五)心跳机制
乔布斯在斯坦福大学的演讲稿——Follow your heart
Amino dye research: lumiprobe fam amine, 6-isomer
mysql 导出查询结果成 excel 文件