对刚
题解:水题,毕竟连我这么个大蒟蒻都做出来了。orz。
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<algorithm> #define N 100005 using namespace std; struct data { int from,to,q; }k,num[N]; int n,t,cnt; int main () { scanf ("%d%d",&n,&t); for (int i=1;i<=n;i++) { if (i==1) { num[i].from=n; num[i].to=i+1; } else if (i==n) { num[i].from=n-1; num[i].to=1; } else { num[i].from=i-1; num[i].to=i+1; } } int x=1; while (num[x].from!=x&&num[x].to!=x) { cnt++; if (cnt==t) { num[num[x].from].to=num[x].to; num[num[x].to].from=num[x].from; cnt=0; } x=num[x].to; } printf ("%d",x); return 0; }
I'm so lost but not afraid ,I've been broken and raise again