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

水过100~~~~~~~~~~~!附代码,一次A!

Posted by woshiliyiyiyiyi at 2012-08-14 10:27:19 on Problem 2498
#include<stdio.h>
#include<string.h>

int main()
{
	int obj[3] = {9, 3, 7};
	char str[10];
	int i, k;
	int n, count;
	int sum, p;

	fscanf(stdin, "%d", &n);
	for (p=1; p<=n; p++)
	{
		sum = 0;
		fscanf(stdin, "%s", str);
		k = strlen(str);
		for (i=k-1; i>=0; i--)
		{
			if (str[i] == '?')
			{
				count = i;
			}
			else
			{
				sum += ((str[i]-'0') * obj[(k-i+2)%3]);
			}
		}

		for (i=0; i<=9; i++)
			if ((sum + i * obj[(k-count+2)%3]) %10 == 0)
			{
				str[count] = i + '0'; 
			}
		printf("Scenario #%d:\n", p);
		printf("%s\n\n", str);
	}

	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