平方数

TimeLimit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K(Java/Other)

Problem Description

Square number isvery popular in ACM/ICPC. Now here is a problem about square number again.
Let's consider such a kind of number called K-Omitted-Square-Number(K-OSN). Nis a K-OSN if:
(1) It is a square number.
(2) Its last digit is not 0.
(3) It's not less than 10^K.
(4) If its last K digits are omitted, it's still a square number.
Now, given an even number K, you have to find the largest K-OSN.

Input

There are multipletest cases in this problem.
The first line will contain a single positive integer T(T<=20) indicatingthe number of test cases. Each test case will be a single line containing aneven number K(2<=K<=200).

Output

For each testcase, print a single line containing the largest K-OSN. In case that it will bevery large, you just need to print the number module 2009. If there are noK-OSN, or if the largest K-OSN doesn't exist, print "Oops!"(withoutquotes).

Sample Input

1
4

Sample Output

197

标程:

#include<stdio.h>
const int MAXK=200;     //最大的K
const int MODNUM=2009;  //用于取模的数

int main()
{
	int tn,i;           //tn为数据组数
	int k,ans;          //题目输入的K
	int digit[MAXK+10],dn; //用于存放答案的数组和数组的长度
	scanf("%d",&tn);
	while(tn--)
	{
		scanf("%d",&k);
		dn=0; digit[++dn]=4;    //根据规律来构造答案
		for(i=1;i<k/2;i++) digit[++dn]=9;
		for(i=1;i<k/2;i++) digit[++dn]=0;
		digit[++dn]=1;
		for(ans=0,i=1;i<=dn;i++) ans=(ans*10+digit[i])%MODNUM;
		ans=(ans*ans)%MODNUM;
		printf("%d\n",ans);
	}
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值