· This is a sample shows the wrong title; modify the sample description: 3,8,5,9.
· This is a sample of explanation, I hurt for half an hour.
Lowe valley entrance: P2069.
·topic:
Th one of N squirrels like to eat fruit sequence from the bottom up in a row, and reference numerals 1,2, ... N. A squirrel began to jump upwardly from the lowermost fruit, and the i-th hop skip can once i * i * i + 1 is divided by the number of fruit I 5 (= i * i * i% 5 + 1), and the foot eat fruit, fruit above if, under gravity, will fall down one space. The 1st hop skip from the first fruit 1 * 1 * 1 + 1% 5 = 2 fruit, skip to the third fruit, and the third eat fruit; from 2nd on 4 fruit (fruit falls third original position) skip 2 * 2 * 2 + 1% 5 = 4 to 8 of the fruit, and the eighth ate; so ....
Of course, there is always a squirrel jump out of the top of the string of fruit, to every K times, it can not eat any of the fruit. Then she returns to the bottom of the fruit, redo its K-th jump, in order to eat the fruit. So, ask it to eat only fruit of m (that is, the fruit of the M-hop eat) What label is?
· Ideas:
Array continues to fall.
The picture shows the dance through the first, second, third value of the number of groups.
· Code:
#include<iostream> #include<cstring> using namespace std; int n,m,t; int a[10005]; int yx(int a) { return (a*a*a)%5+1; } void down(int x,int end) { for(int i=x;i<=end;i++) { a[i]=a[i+1]; } } int main() { cin>>n>>m; int last; int step=1; t=n; for(int i=1;i<=n;i++) a[i]=i; for(int i=1;i<=m;i++) { int s; s=yx(i);//跳过个数 if(step+s<=t)//若没有超出界限 { last=step+s;//所吃果子的位置 step+=s; if(i!=m) {t -; // coordinate position of the highest point - due to a fall, so a number of the highest point also fall down (step, t); // array fall } } the else // If it exceeds the limit { STEP =. 1; / / Skip lowermost first fruit Last + = STEP S; STEP + = S; IF (! I = m) { T--; Down (STEP, T); } } } COUT << a [Last] << endl; return 0; }