Topcoder SRM 619 DIv2 500 --又是耻辱的一题
2024-08-25 17:53:55
这题明明是一个简单的类似约瑟夫环的问题,但是由于细节问题迟迟不能得到正确结果,结果比赛完几分钟才改对。。耻辱。
代码:
#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 ;
}
最新文章
- Mysql - 游标/动态sql/事务
- struts基于ognl的自动类型转换需要注意的地方
- 转!! PreparedStatement是如何防止SQL注入的
- Vector Calculus
- Sla子分类账表结构
- java中 this 和super的用法
- BZOJ3726 : PA2014Final Wykladzina
- 第七课第四节,T语言流程语句(版本5.0)
- 自定义表单input
- IntelliLock托管代码保护和许可授权管理系统软件详细介绍及下载
- POJ 1422
- CSS基础知识笔记(一)
- accel-pptp 部署
- 浅谈Cordova框架的一些理解
- TCP协议三次握手与四次挥手通俗解析
- php解决微信文章图片防盗链
- OpenVDB for Mitsuba
- 深度学习——深度神经网络(DNN)反向传播算法
- 【实战】Docker入门实践二:Docker服务基本操作 和 测试Hello World
- Linux 高级文件管理
热门文章
- 使用svcutil.exe 工具来生成调用文件
- github 基础教程推荐
- 实验12:Problem F: 求平均年龄
- 【读书笔记】iOS-NSDictionary与NSArray的比较
- 基础学习day11--多线程一线程的创建,运行,同步和锁
- iOS之UI--CAGradientLayer
- android 开发小记
- android intent 5.1
- struts2.3.24 + spring4.1.6 + hibernate4.3.11+ mysql5.5.25开发环境搭建及相关说明
- hibernate取出count(*)的办法