#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
int n, m, i;
while( scanf("%d%d", &n, &m)==2)
{
i=1;
while(1)
{
if(m<i)
{
break;
}
m = m-i;
if(i==n)
{
i=1;
i--;
}
i++;
}
printf("%d\n", m);
}
}
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
int n, m, i;
while( scanf("%d%d", &n, &m)==2)
{
i=1;
while(1)
{
if(m<i)
{
break;
}
m = m-i;
if(i==n)
{
i=1;
i--;
}
i++;
}
printf("%d\n", m);
}
}
No comments:
Post a Comment