1 条题解
-
0
C++ :
#include<iostream> #include<cstdio> using namespace std; bool a[250]={0}; int m,n; int main() { //freopen("test5.in","r",stdin); cin>>n>>m; //cout<<n<<' '<<m<<endl; int num=1,i,j,k; for(i=1;i<=m;++i) { j=i*i*i%5+1; k=0; while(1) { if(num>=n) { num=1; k=0; } num++; if(!a[num]) k++; if(k==j) { a[num]=true; if(i==m)cout<<num<<endl; //cout<<j<<' '<<num<<endl; num++; break; } } } return 0; }
Pascal :
program codeup1404; var n,m,t,k,i,s:longint; a:string[200]; begin readln(n); readln(m); t:=1; for k:=1 to n do a:=a+chr(k); for i:=1 to m-1 do begin s:=1+t+(i*i*i mod 5); if s<=n then begin t:=s; delete(a,t,1); n:=n-1; end else begin t:=s-t+1; delete(a,t,1); n:=n-1; end; end; s:=1+t+(m*m*m mod 5); if s<=n then writeln(ord(a[s])) else writeln(ord(a[s-t+1])); end.
- 1
信息
- ID
- 1754
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 10
- 标签
- 递交数
- 1
- 已通过
- 1
- 上传者