Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
1A自我感觉良好#include <iostream> #include <vector> #include <algorithm> #include <set> #include <cstring> #include <stdio.h> #include <fstream> #include <map> using namespace std; int main(int argc, const char * argv[]) { // ifstream cin("input.txt"); // ofstream cout("output.txt"); int N, M, K, J; cin>>N>>M>>K>>J; int ans=0; M %= (N+1); int f = 0; // 倒数c-1次的位置为0,往后推到最后一次,得到相对于n的位置。 for(int i=0; i < K ; i++) { f = (f + M) % (N + 2 - K + i); if(f==0) f = N + 2 - K + i; } // 往前倒推,更新j的位置,找到消除j的迭代次数。 while(J != M) { ans ++; N--; if(M < J) { J = J - M; } else { J = N + 1 - (M - J - 1) ; } } cout<<f<<" "<<ans+1<<endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator