标签:51nod space nbsp show algorithm pre tput nod turn
2个数N和K,表示N个人,数到K出列。(2 <= N, K <= 10^6)
最后剩下的人的编号-----------------------------------------------------------------------------------------------------------------------------------------------------
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; int phi(int n,int k){ if(n<=0) return 1; return (phi(n-1,k)+k)%n; } int main(){ int n,k; cin>>n>>k; printf("%d\n",phi(n,k)+1); return 0; }
标签:51nod space nbsp show algorithm pre tput nod turn
原文地址:http://www.cnblogs.com/redips-l/p/7994922.html