您的位置:首页 > 其它

2017 多校系列 3

2017-08-03 10:51 453 查看


RXD and math

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)

Total Submission(s): 1832    Accepted Submission(s): 745


Problem Description

RXD is a good mathematician.

One day he wants to calculate:

∑i=1nkμ2(i)×⌊nki−−−√⌋

output the answer module 109+7.
1≤n,k≤1018

μ(n)=1(n=1)

μ(n)=(−1)k(n=p1p2…pk)

μ(n)=0(otherwise)

p1,p2,p3…pk are
different prime numbers

 

Input

There are several test cases, please keep reading until EOF.

There are exact 10000 cases.

For each test case, there are 2 numbers n,k.

 

Output

For each test case, output "Case #x: y", which means the test case number and the answer.

 

Sample Input

10 10

Sample Output

Case #1: 999999937

题解:其实就是求n的k次方,用快速幂撸一遍就好了,注意取模,防止超LL

ac code:

#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<string>
//#include<iostream>
//#include<vector>
//#include<queue>
//#include<stack>
//#include<map>
//#include<set>
#define scand(x) scanf("%d",&x)
#define scandd(x,y) scanf("%d%d",&x,&y)
#define mst(a,zero) memset(a,zero,sizeof(a))
#define PARITY(value) (value&1)/alue>0
#define IsPowerOfTwo(n) ((!(n&(n-1)) ) && n)
#define INF 0x3f3f3f3f
#define intinf 1e9
#define llinf 1e18
#define eps 1e-8
#define PI acos(-1.0)
using namespace std;

const int Max=1e9+7;
typedef long long LL;
LL fun(LL x,LL n)
{
LL res=1;
while(n>0)
{
if(n & 1)
res=(res*x)%Max;
x=((x%Max)*(x%Max))%Max;
n >>= 1;
}
return res;
}

int main(){
LL n,k,t,temp;
int cas=0;
while (scanf("%lld%lld",&n,&k)==2){
cas++;
LL nk=fun(n,k);
printf("Case #%d: %lld\n",cas,nk);
}
return 0;
}


RXD's date

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)

Total Submission(s): 1426    Accepted Submission(s): 1085


Problem Description

As we all know that RXD is a life winner, therefore he always goes out, dating with his female friends.

Nevertheless, it is a pity that his female friends don't like extremely hot temperature. Due to this fact, they would not come out if it is higher than 35 degrees.

RXD is omni-potent, so he could precisely predict the temperature in the next t days,
but he is poor in counting.

He wants to know, how many days are there in the next t days,
in which he could go out and date with his female friends.

 

Input

There is only one test case.

The first line consists of one integer t.

The second line consists of t integers ci which
means the temperature in the next t days.

1≤t≤1000 

0≤ci≤50

 

Output

Output an integer which means the answer.

 

Sample Input

5

33 34 35 36 37

 

Sample Output

3

题解:赤裸裸的水题。

ac code:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <iterator>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <cctype>
using namespace std;

#define si1(a) scanf("%d",&a)
#define si2(a,b) scanf("%d%d",&a,&b)
#define sd1(a) scanf("%lf",&a)
#define sd2(a,b) scanf("%lf%lf",&a,&b)
#define ss1(s)  scanf("%s",s)
#define pi1(a)    printf("%d\n",a)
#define pi2(a,b)  printf("%d %d\n",a,b)
#define mset(a,b)   memset(a,b,sizeof(a))
#define forb(i,a,b)   for(int i=a;i<b;i++)
#define ford(i,a,b)   for(int i=a;i<=b;i++)

typedef long long LL;
const int N=1100001;
const int M=6666666;
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-7;

int t;

int main()
{
si1(t);
int num=0;
for(int i=0;i<t;i++)
{
int tmp;
si1(tmp);
if(tmp<=35) num++;
}
printf("%d\n",num);
return 0;
}


未完待续。。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: