KazaQ's Socks (找规律)
#include<iostream> using namespace std; #define ll long long ll n, m; ll t; int main(){ while (cin >> n >> m){ //特判n=2 cout << "Case #" << ++t << ": "; if (n == 2){ cout << (m % 2?1:2) << endl; } else if (n >= m){ cout << m << endl; } else{ m -= n; ll d = m / (n - 1); ll k = m % (n - 1); if (k !=0)cout << k << endl; else{ if (d % 2 == 0)cout << n << endl; else cout << n-1 << endl; } } } }
题意:略
具体规律自己看一下
也就是这样的 1 2 3 4 1 2 3 1 2 4 1 2 3 1 2 4 1 2 3.。。。。
然后,自己去写就是了