这题明明是一个简单的类似约瑟夫环的问题,但是由于细节问题迟迟不能得到正确结果,结果比赛完几分钟才改对。。耻辱。

代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#define ll long long
using namespace std;
#define NN 370000 class ChooseTheBestOne
{
private:
public:
ll calc3(int n)
{
return (ll)pow(n,);
}
int countNumber(int N)
{
ll now = ,remain = (ll)(N-);
ll rd = ;
ll pos;
int has[];
memset(has,-,sizeof(has));
has[] = ;
while(rd < N)
{
while(has[now] == )
{
now = (now+)%N;
}
ll call = calc3(rd);
ll add = (call-)%remain;
ll k = ;
for(pos=now;k<add;)
{
pos = (pos+)%N;
if(has[pos] != )
k++;
}
has[pos] = ;
now = (pos+)%N;
//cout<<"出去: "<<pos+1<<" 现在"<<now+1<<endl;
remain--;
rd++; }
ll i;
for(i=;i<N;i++)
{
if(has[i] == -)
{
return i+;
}
}
}
}; int main()
{
ChooseTheBestOne *kc = new ChooseTheBestOne();
cout<<(*kc).countNumber()<<endl;
return ;
}

最新文章

  1. Mysql - 游标/动态sql/事务
  2. struts基于ognl的自动类型转换需要注意的地方
  3. 转!! PreparedStatement是如何防止SQL注入的
  4. Vector Calculus
  5. Sla子分类账表结构
  6. java中 this 和super的用法
  7. BZOJ3726 : PA2014Final Wykladzina
  8. 第七课第四节,T语言流程语句(版本5.0)
  9. 自定义表单input
  10. IntelliLock托管代码保护和许可授权管理系统软件详细介绍及下载
  11. POJ 1422
  12. CSS基础知识笔记(一)
  13. accel-pptp 部署
  14. 浅谈Cordova框架的一些理解
  15. TCP协议三次握手与四次挥手通俗解析
  16. php解决微信文章图片防盗链
  17. OpenVDB for Mitsuba
  18. 深度学习——深度神经网络(DNN)反向传播算法
  19. 【实战】Docker入门实践二:Docker服务基本操作 和 测试Hello World
  20. Linux 高级文件管理

热门文章

  1. 使用svcutil.exe 工具来生成调用文件
  2. github 基础教程推荐
  3. 实验12:Problem F: 求平均年龄
  4. 【读书笔记】iOS-NSDictionary与NSArray的比较
  5. 基础学习day11--多线程一线程的创建,运行,同步和锁
  6. iOS之UI--CAGradientLayer
  7. android 开发小记
  8. android intent 5.1
  9. struts2.3.24 + spring4.1.6 + hibernate4.3.11+ mysql5.5.25开发环境搭建及相关说明
  10. hibernate取出count(*)的办法