码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 5833Zhu and 772002

时间:2016-08-14 20:35:17      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:

Zhu and 772002

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 104    Accepted Submission(s): 29


Problem Description
Zhu and 772002 are both good at math. One day, Zhu wants to test the ability of 772002, so he asks 772002 to solve a math problem. 

But 772002 has a appointment with his girl friend. So 772002 gives this problem to you.

There are n numbers a1,a2,...,an. The value of the prime factors of each number does not exceed 2000, you can choose at least one number and multiply them, then you can get a number b.

How many different ways of choices can make b is a perfect square number. The answer maybe too large, so you should output the answer modulo by 1000000007.
 


Input
First line is a positive integer T , represents there are T test cases.

For each test case:

First line includes a number n(1n300),next line there are n numbers a1,a2,...,an,(1ai1018).
 


Output
For the i-th test case , first output Case #i: in a single line.

Then output the answer of i-th test case modulo by 1000000007.
 


Sample Input
2
3
3 3 4
3
2 2 2
 
Sample Output
Case #1:
3
Case #2:
3
 模拟取余

一开始 无脑java大数。mle手动释放内存也不行。看了看提交页面  没有用java过的。。

/* ***********************************************
Author        :guanjun
Created Time  :2016/8/14 14:04:01
File Name     :hdu5832.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 10010
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
priority_queue<int,vector<int>,greater<int> >pq;
struct Node{
    int x,y;
};
struct cmp{
    bool operator()(Node a,Node b){
        if(a.x==b.x) return a.y> b.y;
        return a.x>b.x;
    }
};

bool cmp(int a,int b){
    return a>b;
}
char s[10000010];
int a[10000010];
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
    #endif
    //freopen("out.txt","w",stdout);
    int cas=0;
    while(scanf("%s",&s)!=EOF){
        int n=strlen(s);
        for(int i=0;i<n;i++)a[i]=s[i]-0;
        for(int i=1;i<n;i++){
            a[i]=(a[i-1]*10+a[i])%10001;
        }
        if(a[n-1]){
            printf("Case #%d: NO\n",++cas);
        }
        else printf("Case #%d: YES\n",++cas);
    }
    return 0;
}

 

HDU 5833Zhu and 772002

标签:

原文地址:http://www.cnblogs.com/pk28/p/5770838.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!