Topcoder SRM 619 DIv2 500 --又是耻辱的一题
这题明明是一个简单的类似约瑟夫环的问题,但是由于细节问题迟迟不能得到正确结果,结果比赛完几分钟才改对。。耻辱。
代码:
#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 ;
}
Topcoder SRM 619 DIv2 500 --又是耻辱的一题的更多相关文章
- 求拓扑排序的数量,例题 topcoder srm 654 div2 500
周赛时遇到的一道比较有意思的题目: Problem Statement There are N rooms in Maki's new house. The rooms are number ...
- topcoder SRM 619 DIV2 GoodCompanyDivTwo
注意题目给的最后一句话,如果部门任何employee都做不同类型的工作,则这个部门是一个diverse,题目是计算department的diverse数 读起来感觉有点别扭,英语没学好的原因 int ...
- topcoder srm 628 div2 250 500
做了一道题,对了,但是还是掉分了. 第二道题也做了,但是没有交上,不知道对错. 后来交上以后发现少判断了一个条件,改过之后就对了. 第一道题爆搜的,有点麻烦了,其实几行代码就行. 250贴代码: #i ...
- Topcoder Srm 673 Div2 1000 BearPermutations2
\(>Topcoder \space Srm \space 673 \space Div2 \space 1000 \space BearPermutations2<\) 题目大意 : 对 ...
- Topcoder Srm 671 Div2 1000 BearDestroysDiv2
\(>Topcoder \space Srm \space 671 \space Div2 \space 1000 \space BearDestroysDiv2<\) 题目大意 : 有一 ...
- Topcoder srm 632 div2
脑洞太大,简单东西就是想复杂,活该一直DIV2; A:水,基本判断A[I]<=A[I-1],ANS++; B:不知道别人怎么做的,我的是100*N*N;没办法想的太多了,忘记是连续的数列 我们枚 ...
- topcoder SRM 628 DIV2 BracketExpressions
先用dfs搜索所有的情况,然后判断每种情况是不是括号匹配 #include <vector> #include <string> #include <list> # ...
- topcoder SRM 628 DIV2 BishopMove
题目比较简单. 注意看测试用例2,给的提示 Please note that this is the largest possible return value: whenever there is ...
- Topcoder SRM 683 Div2 B
贪心的题,从左向右推过去即可 #include <vector> #include <list> #include <map> #include <set&g ...
随机推荐
- mysql init-file参数中语句限制
mysql 启动选项中的init-file文件的内容目测只能是dml语句,不能包含ddl,否则执行就会报错,但不影响启动本身..太扯了..
- HTML Jquery
在<网页制作Dreamweaver(悬浮动态分层导航)>中,运用到了jQuery的技术,轻松实现了菜单的下拉.显示.隐藏的效果,不必再用样式表一点点地修改,省去了很多麻烦,那么jQuery ...
- mongodb c#语法基础
这里采用的是mongoDB官网推荐使用.net驱动: http://mongodb.github.io/mongo-csharp-driver/2.0/getting_started/quick_to ...
- Mssql链接mysql数据库
最近在做mysql数据库实时同步到mssql数据库的方案,花了一周时间,测试通过了,在实际机器上测试出现了若干问题.第一个问题就是在mssql上链接mysql的问题. 第一步,安装 Mysql ODB ...
- SharePoint 2010 ——自定义上传页面与多文件上传解决方案
最近项目遇到一个很麻烦的问题,原以为很容易解决,结果搞了那么久,先开个头,再慢慢写 SharePoint 2010 ——自定义上传页面与多文件上传解决方案 1.创建Sharepoint空白项目,创建应 ...
- Android动画translate坐标图
X坐标图示: Y坐标图示:
- Servlet API遍程常用接口和类
本文主要总结Servlet API遍程常用接口和类 Servlet API http://tomcat.apache.org/tomcat-5.5-doc/servletapi/index.html ...
- 认识Runtime1
认识Runtime1 什么是id? id在objc.h中的定义如下: typedef struct objc_object *id; 那么什么是objc_object呢? objc_object在ob ...
- 网络开始---多线程---GCD-01-基本使用(掌握)(六)
/** GCD两个核心概念:任何和队列 任务:执行什么操作 队列:用来存放任务 使用就2个步骤 1.定制任务 2.将任务添加到队列中 任务的取出队列原则:FIFO原则: 先进先出,后进后出 */ #i ...
- 搭建openvpn 未完成。。。
轻松构建自己的OpenVPN家庭服务器(VMware+Amahi) http://os.51cto.com/art/201107/277146_all.htm 这是教程 不用安装第一步的,直接把下载 ...