1 条题解
-
0
C :
#include <stdio.h> int main() { int n,i,s=0; while(scanf("%d",&n) !=EOF) { s=0; for (i=2;i<=n;i++) s=(s+3)%i; printf("%d\n",s+1); } }
C++ :
#include<iostream> #include<algorithm> using namespace std; struct a{ int n; int f; }; a text[100001]; int main(){ int n; //freopen("1cin.in", "r", stdin); //freopen("1cin.out", "w", stdout); while(scanf("%d",&n) != EOF){ for(int i = 1;i <= n;i++){ text[i].n = i; text[i].f = 1; } int count = 1; while(1){ int t = 0; for(int i = 1;i <= n;i++){ if(text[i].f == 1){ t++; } } if(t == 1){ for(int i = 1;i <= n;i++){ if(text[i].f == 1){ cout<<text[i].n<<endl; } } break; } int f = 3; while(1){ if(text[count].f == 1){ f--; } if(f == 0){ text[count].f = 0; break; } if(count == n){ count = 0; } count++; } } } }
- 1
信息
- ID
- 933
- 时间
- 2000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者