Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
谁能为我程序给出一个反例?不胜感激。。。#include <stdio.h> int cnt[100]; int N,K; int findMin(int c, int n, int m) { int t,i; int min=c*n+m; for(i=c; i+c>=0; i-=2) { t= i*n + m; if(t>=0) t%=K; else t=K + t%K; if(2*t>K) t=K-t; if(t<min) min=t; } return min; } int main() { int i,j,t; scanf("%d%d", &N, &K); for(i=0; i<N; i++) { scanf("%d", &t); t%=K; t=(t+K)%K; cnt[t]++; } t=0; for(i=K-1; i>0; i--) if(cnt[i]) { t=findMin(cnt[i], i, t); //printf("i = %d, t = %d\n",i,t); } if(t) puts("Not divisible"); else puts("Divisible"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator