X-man

导航

sicily 1001. Black Magic

#include<stdio.h>
#include<string.h>
int main()
{
    int _case;
    int n,m,k;

    scanf("%d",&_case);
    while(_case--)
    {
        scanf("%d %d %d",&n,&m,&k);
        int t,sum=0;
        //k=p;
        for(t=n;t>=0;t-=m)
        {
            sum+=t;
            if(k-sum<=0)break;
        }
        //printf("%d %d\n",sum,t);
        if(t>=0)printf("%d\n",n-(sum-k));
        else printf("0\n");
    }
    return 0;
} 

数学找规律题:

posted on 2013-04-30 19:39  雨钝风轻  阅读(130)  评论(0编辑  收藏  举报