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; }
数学找规律题: