http://codeforces.com/contest/92

A

 1 #include<iostream>
 2 using namespace std;
 3 #define lson l,mid,rt<<1
 4 #define rson mid+1,r,rt<<1|1
 5 #define sqr(x) ((x)*(x))
 6 #define maxn 100005
 7 typedef long long ll;
 8 typedef unsigned long long ull;
 9 const ull MOD=257;
10 /*#ifndef ONLINE_JUDGE
11         freopen("1.txt","r",stdin);
12 #endif */
13 
14 
15 
16 int main(){
17     #ifndef ONLINE_JUDGE
18      //   freopen("1.txt","r",stdin);
19     #endif
20     std::ios::sync_with_stdio(false);
21     int n,m;
22     cin>>n>>m;
23     int i=0;
24     while(i+1<=m){
25         m-=i+1;
26         i++;
27         if(i==n) i%=n;
28     }
29     cout<<m<<endl;
30 }
View Code

相关文章: