Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

谁能为我程序给出一个反例?不胜感激。。。

Posted by qiqilrq at 2007-03-12 02:11:41 on Problem 1745
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator