#include<bits/stdc++.h> using namespace std; int main(){ int n; while(scanf("%d",&n)!=EOF){ if(n == 0) break; int x = n; int a[10000000]; for(int i = 1; i <= n; i++){ a[i] = i; } for(int j = 1; x != 1; j++){ if(j % 3 != 0){ n++; a[n] = a[j]; }else{ x--; } } printf("%d\n",a[n]); } } |
Double click to view unformatted code.