这场打得还是比较爽的,但是队友差一点就再过一题,还是难受啊。

每天都有新的难过

A. Magic Mirror

Jessie has a magic mirror.

Every morning she will ask the mirror: 'Mirror mirror tell me, who is the most beautiful girl in the world?' If the mirror says her name, she will praise the mirror: 'Good guy!', but if the mirror says the name of another person, she will assail the mirror: 'Dare you say that again?'

Today Jessie asks the mirror the same question above, and you are given a series of mirror's answers. For each answer, please output Jessie's response. You can assume that the uppercase or lowercase letters appearing anywhere in the name will have no influence on the answer. For example, 'Jessie' and 'jessie' represent the same person.

Input

The first line contains an integer T(1 \le T \le 100)T(1≤T≤100), which is the number of test cases.

Each test case contains one line with a single-word name, which contains only English letters. The length of each name is no more than 1515.

Output

For each test case, output one line containing the answer.

样例输入复制

2
Jessie
Justin

样例输出复制

Good guy!
Dare you say that again?

题目来源

ACM-ICPC 2018 焦作赛区网络预赛

大小写转换一下

#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lson l,(l+r)/2,rt<<1
#define rson (l+r)/2+1,r,rt<<1|1
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define pll pair<long long,long long>
#define pii pair<int,int>
#define pq priority_queue
const int N=1e5+,MD=1e9+,INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-,e=exp(),PI=acos(-.);
int a[N];
int main()
{
ios::sync_with_stdio(false),cin.tie(),cout.tie();
int T;
cin>>T;
while(T--)
{
string s;
cin>>s;
for(int i=;s[i];i++)if(s[i]>='A'&&s[i]<='Z')s[i]+=;
if(s=="jessie")cout<<"Good guy!\n";
else cout<<"Dare you say that again?\n";
}
return ;
}

B. Mathematical Curse

A prince of the Science Continent was imprisoned in a castle because of his contempt for mathematics when he was young, and was entangled in some mathematical curses. He studied hard until he reached adulthood and decided to use his knowledge to escape the castle.

There are NN rooms from the place where he was imprisoned to the exit of the castle. In the i^{th}ith room, there is a wizard who has a resentment value of a[i]a[i]. The prince has MM curses, the j^{th}jthcurse is f[j]f[j], and f[j]f[j] represents one of the four arithmetic operations, namely addition('+'), subtraction('-'), multiplication('*'), and integer division('/'). The prince's initial resentment value is KK. Entering a room and fighting with the wizard will eliminate a curse, but the prince's resentment value will become the result of the arithmetic operation f[j]f[j] with the wizard's resentment value. That is, if the prince eliminates the j^{th}jth curse in the i^{th}ithroom, then his resentment value will change from xx to (x\ f[j]\ a[i]x f[j] a[i]), for example, when x=1, a[i]=2, f[j]=x=1,a[i]=2,f[j]='+', then xxwill become 1+2=31+2=3.

Before the prince escapes from the castle, he must eliminate all the curses. He must go from a[1]a[1] to a[N]a[N] in order and cannot turn back. He must also eliminate the f[1]f[1] to f[M]f[M] curses in order(It is guaranteed that N\ge MN≥M). What is the maximum resentment value that the prince may have when he leaves the castle?

Input

The first line contains an integer T(1 \le T \le 1000)T(1≤T≤1000), which is the number of test cases.

For each test case, the first line contains three non-zero integers: N(1 \le N \le 1000), M(1 \le M \le 5)N(1≤N≤1000),M(1≤M≤5)and K(-1000 \le K \le 1000K(−1000≤K≤1000), the second line contains NN non-zero integers: a[1], a[2], ..., a[N](-1000 \le a[i] \le 1000)a[1],a[2],...,a[N](−1000≤a[i]≤1000), and the third line contains MM characters: f[1], f[2], ..., f[M](f[j] =f[1],f[2],...,f[M](f[j]='+','-','*','/', with no spaces in between.

Output

For each test case, output one line containing a single integer.

样例输入复制

3
2 1 5
2 3
/
3 2 1
1 2 3
++
4 4 5
1 2 3 4
+-*/

样例输出复制

2
6
3

题目来源

ACM-ICPC 2018 焦作赛区网络预赛

有一个负的,还有一个正的,所以都要进入dp

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1LL<<;
ll dp1[][],dp2[][];
int a[];
char s[];
ll calc(ll x,char c,int y)
{
if(c=='-') return x-y;
if(c=='+') return x+y;
if(c=='/') return x/y;
if(c=='*') return x*y;
}
int main()
{
int T,n,m,k;
scanf("%d",&T);
while(T--)
{
scanf("%d%d%d",&n,&m,&k);
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
dp1[i][j]=-INF,dp2[i][j]=INF;
for(int i=;i<=n;i++)
scanf("%d",&a[i]);
for(int i=;i<=n;i++)
dp1[i][]=dp2[i][]=k;
scanf("%s",s+);
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
{
dp1[i][j]=dp1[i-][j];
dp2[i][j]=dp2[i-][j];
if(dp1[i-][j-]!=-INF) dp1[i][j]=max(dp1[i][j],calc(dp1[i-][j-],s[j],a[i]));
if(dp2[i-][j-]!=INF) dp1[i][j]=max(dp1[i][j],calc(dp2[i-][j-],s[j],a[i]));
if(dp1[i-][j-]!=-INF) dp2[i][j]=min(dp2[i][j],calc(dp1[i-][j-],s[j],a[i]));
if(dp2[i-][j-]!=INF) dp2[i][j]=min(dp2[i][j],calc(dp2[i-][j-],s[j],a[i]));
}
printf("%lld\n",dp1[n][m]);
}
return ;
}

E. Jiu Yuan Wants to Eat

You ye Jiu yuan is the daughter of the Great GOD Emancipator. And when she becomes an adult, she will be queen of Tusikur, so she wanted to travel the world while she was still young. In a country, she found a small pub called Whitehouse. Just as she was about to go in for a drink, the boss Carola appeared. And ask her to solve this problem or she will not be allowed to enter the pub. The problem description is as follows:

There is a tree with nn nodes, each node iicontains weight a[i]a[i], the initial value of a[i]a[i] is 00. The root number of the tree is 11. Now you need to do the following operations:

1)1) Multiply all weight on the path from uuto vv by xx

2)2) For all weight on the path from uu to vv, increasing xx to them

3)3) For all weight on the path from uu to vv, change them to the bitwise NOT of them

4)4) Ask the sum of the weight on the path from uu to vv

The answer modulo 2^{64}264.

Jiu Yuan is a clever girl, but she was not good at algorithm, so she hopes that you can help her solve this problem. Ding\backsim\backsim\backsim∽∽∽

The bitwise NOT is a unary operation that performs logical negation on each bit, forming the ones' complement of the given binary value. Bits that are 00become 11, and those that are 11 become 00. For example:

NOT 0111 (decimal 7) = 1000 (decimal 8)

NOT 10101011 = 01010100

Input

The input contains multiple groups of data.

For each group of data, the first line contains a number of nn, and the number of nodes.

The second line contains (n - 1)(n−1)integers b_ibi​, which means that the father node of node (i +1)(i+1) is b_ibi​.

The third line contains one integer mm, which means the number of operations,

The next mm lines contain the following four operations:

At first, we input one integer opt

1)1) If opt is 11, then input 33 integers, u, v, xu,v,x, which means multiply all weight on the path from uu to vv by xx

2)2) If opt is 22, then input 33 integers, u, v, xu,v,x, which means for all weight on the path from uu to vv, increasing xx to them

3)3) If opt is 33, then input 22 integers, u, vu,v, which means for all weight on the path from uu to vv, change them to the bitwise NOT of them

4)4) If opt is 44, then input 22 integers, u, vu,v, and ask the sum of the weights on the path from uu to vv

1 \le n,m,u,v \le 10^51≤n,m,u,v≤105

1 \le x < 2^{64}1≤x<264

Output

For each operation 44, output the answer.

样例输入复制

7
1 1 1 2 2 4
5
2 5 6 1
1 1 6 2
4 5 6
3 5 2
4 2 2
2
1
4
3 1 2
4 1 2
3 1 1
4 1 1

样例输出复制

5
18446744073709551613
18446744073709551614
0

题目来源

ACM-ICPC 2018 焦作赛区网络预赛

队友LCT差一点调出来唉

划重点 按位取反是*-1+MAX

#include<iostream>
#include<cstdio>
#include<cstring>
#define N 100010
using namespace std;
typedef unsigned long long ull;
ull st[N],n,m,q,x,y,op,w,rev[N],size[N],c[N][],fa[N];
ull mt[N],a[N],v[N],s[N];
bool isroot(ull x)
{
return c[fa[x]][]!=x&&c[fa[x]][]!=x;
}
void updata(ull x)
{
ull l=c[x][],r=c[x][];
size[x]=size[l]+size[r]+;
s[x]=s[l]+s[r]+v[x];
}
void paint(ull x,ull cc,ull aa)
{
if (!x) return;
v[x]=v[x]*cc+aa;
s[x]=s[x]*cc+size[x]*aa;
a[x]=a[x]*cc+aa;
mt[x]=mt[x]*cc;
}
void pushdown(ull x)
{
ull l=c[x][],r=c[x][];
if (rev[x])
{
rev[l]^=;
rev[r]^=;
rev[x]^=;
swap(c[x][],c[x][]);
}
ull aa=a[x],cc=mt[x];
a[x]=;
mt[x]=;
if (cc!=||aa!=)
{
paint(l,cc,aa);
paint(r,cc,aa);
}
}
void rotata(ull x)
{
ull y=fa[x],z=fa[y],l,r;
if (x==c[y][]) l=;
else l=;
r=l^;
if (!isroot(y))
{
if (c[z][]==y)c[z][]=x;
else c[z][]=x;
}
fa[x]=z;
fa[y]=x;
fa[c[x][r]]=y;
c[y][l]=c[x][r];
c[x][r]=y;
updata(y);
updata(x);
}
void splay(ull x)
{
ull top();
st[++top]=x;
for(ull i=x; !isroot(i); i=fa[i]) st[++top]=fa[i];
for (ull i=top; i; i--) pushdown(st[i]);
while (!isroot(x))
{
ull y=fa[x],z=fa[y];
if (!isroot(y))
{
if (c[y][]==x^c[z][]==y) rotata(x);
else rotata(y);
}
rotata(x);
}
}
void access(ull x)
{
ull t();
while (x)
{
splay(x);
c[x][]=t;
t=x;
updata(x);
x=fa[x];
}
}
void makeroot(ull x)
{
access(x);
splay(x);
rev[x]^=;
}
void link(ull x,ull y)
{
makeroot(x);
fa[x]=y;
}
void cut(ull x,ull y)
{
makeroot(x);
access(y);
splay(y);
c[y][]=fa[x]=;
}
void split(ull x,ull y)
{
makeroot(y);
access(x);
splay(x);
}
int main()
{
while(scanf("%llu",&n)!=EOF)
{
for (ull i=; i<=n; i++) v[i]=,size[i]=s[i]=mt[i]=;
memset(c,,sizeof c);
memset(fa,,sizeof fa);
for (ull i=; i<=n; i++)
{
scanf("%llu",&y);
link(y,i);
}
scanf("%llu",&q);
for (ull i=; i<=q; i++)
{
scanf("%llu%llu%llu",&op,&x,&y);
if (op==)//+w
{
scanf("%llu",&w);
split(x,y);
paint(x,,w);
}
if (op==)//not 2^64-1 18446744073709551615
{
split(x,y);
paint(x,-,18446744073709551615ull);
}
if (op==)//*w
{
scanf("%llu",&w);
split(x,y);
paint(x,w,);
}
if (op==)//u,v
{
split(x,y);
printf("%llu\n",s[x]);
}
}
}
return ;
}

F. Modular Production Line

An automobile factory has a car production line. Now the market is oversupply and the production line is often shut down. To make full use of resources, the manager divides the entire production line into NN parts (1...N)(1...N). Some continuous parts can produce sub-products. And each of sub-products has their own value. The manager will use spare time to produce sub-products to make money. Because of the limited spare time, each part of the production line could only work at most KK times. And Because of the limited materials, each of the sub-products could be produced only once. The manager wants to know the maximum value could he make by produce sub-products.

Input

The first line of input is TT, the number of test case.

The first line of each test case contains three integers, N, KN,K and MM. (MM is the number of different sub-product).

The next MM lines each contain three integers A_i, B_i, W_iAi​,Bi​,Wi​ describing a sub-product. The sub-product has value W_iWi​. Only A_iAi​ to B_iBi​ parts work simultaneously will the sub-product be produced (include A_iAi​ to B_iBi​).

1 \le T \le 1001≤T≤100

1 \le K \le M \le 2001≤K≤M≤200

1 \le N \le 10^51≤N≤105

1 \le A_i \le B_i \le N1≤Ai​≤Bi​≤N

1 \le W_i \le 10^51≤Wi​≤105

Output

For each test case output the maximum value in a separate line.

样例输入复制

4
10 1 3
1 2 2
2 3 4
3 4 8
10 1 3
1 3 2
2 3 4
3 4 8
100000 1 3
1 100000 100000
1 2 3
100 200 300
100000 2 3
1 100000 100000
1 150 301
100 200 300

样例输出复制

10
8
100000
100301

题目来源

ACM-ICPC 2018 焦作赛区网络预赛

建图网络流

先对区间的端点进行离散化,然后建边

#include<bits/stdc++.h>
using namespace std; const int N=1e4+;
const int M=1e5+;
const int INF=0x3f3f3f3f; int FIR[N],TO[M],CAP[M],FLOW[M],COST[M],NEXT[M],tote;
int pre[N],dist[N],q[];
bool vis[N];
int n,m,S,T;
void init()
{
tote=;
memset(FIR,-,sizeof(FIR));
}
void add(int u,int v,int cap,int cost)
{
TO[tote]=v;
CAP[tote]=cap;
FLOW[tote]=;
COST[tote]=cost;
NEXT[tote]=FIR[u];
FIR[u]=tote++; TO[tote]=u;
CAP[tote]=;
FLOW[tote]=;
COST[tote]=-cost;
NEXT[tote]=FIR[v];
FIR[v]=tote++;
}
bool SPFA(int s, int t)
{
memset(dist,INF,sizeof(dist));
memset(vis,false,sizeof(vis));
memset(pre,-,sizeof(pre));
dist[s] = ;
vis[s]=true;
q[]=s;
int head=,tail=;
while(head!=tail)
{
int u=q[++head];
vis[u]=false;
for(int v=FIR[u]; v!=-; v=NEXT[v])
{
if(dist[TO[v]]>dist[u]+COST[v]&&CAP[v]>FLOW[v])
{
dist[TO[v]]=dist[u]+COST[v];
pre[TO[v]]=v;
if(!vis[TO[v]])
{
vis[TO[v]] = true;
q[++tail]=TO[v];
}
}
}
}
return pre[t]!=-;
}
void MCMF(int s, int t, int &cost, int &flow)
{
flow=cost=;
while(SPFA(s,t))
{
int Min=INF;
for(int v=pre[t]; v!=-; v=pre[TO[v^]])
Min=min(Min, CAP[v]-FLOW[v]);
for(int v=pre[t]; v!=-; v=pre[TO[v^]])
{
FLOW[v]+=Min;
FLOW[v^]-=Min;
cost+=COST[v]*Min;
}
flow+=Min;
}
}
int l[],r[],c[];
int a[],b[];
int main()
{
int ca,k;
scanf("%d",&ca);
while(ca--)
{
scanf("%d%d%d",&n,&k,&m);
init();
int num=;
for(int i=; i<=m; i++)
{
scanf("%d%d%d",&l[i],&r[i],&c[i]),r[i]+=;
a[++num]=l[i],a[++num]=r[i];
}
sort(a+,a+num+);
num=unique(a+,a+num+)-a-;
for(int i=;i<=num;i++)b[a[i]]=i;
S=;
T=num+;
for(int i=;i<=num;i++)add(i,i+,k,);
for(int i=;i<=m;i++)add(b[l[i]],b[r[i]],,-c[i]);
int cost,flow;
MCMF(S,T,cost,flow);
printf("%d\n",-cost);
}
return ;
}

G. Give Candies

There are NN children in kindergarten. Miss Li bought them NN candies. To make the process more interesting, Miss Li comes up with the rule: All the children line up according to their student number (1...N)(1...N), and each time a child is invited, Miss Li randomly gives him some candies (at least one). The process goes on until there is no candy. Miss Li wants to know how many possible different distribution results are there.

Input

The first line contains an integer TT, the number of test case.

The next TT lines, each contains an integer NN.

1 \le T \le 1001≤T≤100

1 \le N \le 10^{100000}1≤N≤10100000

Output

For each test case output the number of possible results (mod 1000000007).

样例输入复制

1
4

样例输出复制

8

题目来源

ACM-ICPC 2018 焦作赛区网络预赛

输出2^(n-1),可以直接降幂啊,就是一个大数取余

#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lson l,(l+r)/2,rt<<1
#define rson (l+r)/2+1,r,rt<<1|1
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define pll pair<long long,long long>
#define pii pair<int,int>
#define pq priority_queue
const int N=1e5+,MD=1e9+,INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-,e=exp(),PI=acos(-.);
char s[N];
ll la(ll m)
{
int l=strlen(s);
ll ans=;
for(int i=;i<l;i++)ans=(ans*+s[i]-'')%m;
return ans;
}
ll lb(ll a,ll b)
{
ll ans=;
for(;b;a=a*a%MD,b>>=)if(b&)ans=ans*a%MD;
return ans;
}
int main()
{
int T;
scanf("%d",&T);
getchar();
while(T--)
{
gets(s);
ll k=(la(MD-)-+MD)%MD;
printf("%lld\n",lb(,k));
}
return ;
}

H. String and Times

Now you have a string consists of uppercase letters, two integers AA and BB. We call a substring wonderful substring when the times it appears in that string is between AA and BB (A \le times \le BA≤times≤B). Can you calculate the number of wonderful substrings in that string?

Input

Input has multiple test cases.

For each line, there is a string SS, two integers AA and BB.

\sum length(S) \le 2 \times 10^6∑length(S)≤2×106,

1 \le A \le B \le length(S)1≤A≤B≤length(S)

Output

For each test case, print the number of the wonderful substrings in a line.

样例输入复制

AAA 2 3
ABAB 2 2

样例输出复制

2
3

题目来源

ACM-ICPC 2018 焦作赛区网络预赛

SAM直接过啊,原题

#include<stdio.h>
#include<string.h>
const int N=2e5+;
int go[N][],mx[N],fa[N],sa[N],w[N],s[N/];
int k,t,last,n;
char a[N];
int newid(int x)
{
memset(go[x],,sizeof go[x]);
w[x]=;
return x;
}
void add(int c)
{
int p=last,np=last=newid(++t);
mx[np]=mx[p]+,w[np]=;
for(; p&&!go[p][c]; p=fa[p])go[p][c]=np;
if(!p)fa[np]=;
else
{
int q=go[p][c];
if(mx[q]==mx[p]+)fa[np]=q;
else
{
int nq=newid(++t);
mx[nq]=mx[p]+;
memcpy(go[nq],go[q],sizeof go[q]);
fa[nq]=fa[q];
fa[q]=fa[np]=nq;
for(; go[p][c]==q; p=fa[p])go[p][c]=nq;
}
}
}
void pre()
{
memset(s,,sizeof s);
for(int i=; i<=t; i++)s[mx[i]]++;
for(int i=; i<=n; i++)s[i]+=s[i-];
for(int i=t; i; i--)sa[s[mx[i]]--]=i;
for(int i=t; i; i--)w[fa[sa[i]]]+=w[sa[i]];
}
int main()
{
while(~scanf("%s",a+))
{
n=strlen(a+),t=,last=newid(++t);
for(int i=; i<=n; i++)add(a[i]-'A');
pre();
long long ans=;
int l,r;
scanf("%d%d",&l,&r);
for(int i=; i<=t; i++)
if(w[i]>=l&&w[i]<=r)ans+=mx[i]-mx[fa[i]];
printf("%lld\n",ans);
}
return ;
}

I. Save the Room

Bob is a sorcerer. He lives in a cuboid room which has a length of AA, a width of BB and a height of CC, so we represent it as AA * BB * CC. One day, he finds that his room is filled with unknown dark energy. Bob wants to neutralize all the dark energy in his room with his light magic. He can summon a 11 * 11 * 22cuboid at a time to neutralize dark energy. But the cuboid must be totally in dark energy to take effect. Can you foresee whether Bob can save his room or not?

Input

Input has TT test cases. T \le 100T≤100

For each line, there are three integers A, B, CA,B,C.

1 \le A, B, C \le 1001≤A,B,C≤100

Output

For each test case, if Bob can save his room, print"Yes", otherwise print"No".

样例输入复制

1 1 2
1 1 4
1 1 1

样例输出复制

Yes
Yes
No

题目来源

ACM-ICPC 2018 焦作赛区网络预赛

你去组合的体积肯定是个偶数,三个奇数肯定不行啊

#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lson l,(l+r)/2,rt<<1
#define rson (l+r)/2+1,r,rt<<1|1
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define pll pair<long long,long long>
#define pii pair<int,int>
#define pq priority_queue
const int N=1e5+,MD=1e9+,INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-,e=exp(),PI=acos(-.);
int a[N];
int main()
{
ios::sync_with_stdio(false),cin.tie(),cout.tie();
int A,B,C;
while(cin>>A>>B>>C)
{ int f=A*B*C;
if(f&)cout<<"No\n";
else cout<<"Yes\n";
}
return ;
}

J. Participate in E-sports

Jessie and Justin want to participate in e-sports. E-sports contain many games, but they don't know which one to choose, so they use a way to make decisions.

They have several boxes of candies, and there are ii candies in the i^{th}ith box, each candy is wrapped in a piece of candy paper. Jessie opens the candy boxes in turn from the first box. Every time a box is opened, Jessie will take out all the candies inside, finish it, and hand all the candy papers to Justin.

When Jessie takes out the candies in the N^{th}Nth box and hasn't eaten yet, if the amount of candies in Jessie's hand and the amount of candy papers in Justin's hand are both perfect square numbers, they will choose Arena of Valor. If only the amount of candies in Jessie's hand is a perfect square number, they will choose Hearth Stone. If only the amount of candy papers in Justin's hand is a perfect square number, they will choose Clash Royale. Otherwise they will choose League of Legends.

Now tell you the value of NN, please judge which game they will choose.

Input

The first line contains an integer T(1 \le T \le 800)T(1≤T≤800) , which is the number of test cases.

Each test case contains one line with a single integer: N(1 \le N \le 10^{200})N(1≤N≤10200) .

Output

For each test case, output one line containing the answer.

样例输入复制

4
1
2
3
4

样例输出复制

Arena of Valor
Clash Royale
League of Legends
Hearth Stone

题目来源

ACM-ICPC 2018 焦作赛区网络预赛

判断n和n*(n-1)/2是不是平方数,直接上我们的牛顿迭代啊

import java.math.*;
import java.util.*;
public class Main {
public static void main(String args[])
{
Scanner cin=new Scanner(System.in);
int T=cin.nextInt();
for(int i=;i<T;i++)
{
BigInteger n=cin.nextBigInteger();
BigInteger x=cal(n);
BigInteger y=n.multiply(n.subtract(BigInteger.valueOf())).shiftRight();
BigInteger z=cal(y);
if(x.multiply(x).equals(n)==true)
{
if(z.multiply(z).equals(y)==true)
System.out.println("Arena of Valor");
else
System.out.println("Hearth Stone");
}
else
{
if(z.multiply(z).equals(y)==true)
System.out.println("Clash Royale");
else
System.out.println("League of Legends");
} }
}
static BigInteger cal(BigInteger x)
{
BigInteger ans=BigInteger.valueOf();
if(x.equals(BigInteger.valueOf())==true)return ans;
BigInteger rt=BigInteger.valueOf();
BigInteger lst=BigInteger.valueOf(-);
while(true)
{
BigInteger nxt=rt.add(x.divide(rt)).shiftRight();
if(nxt.equals(lst)==true)
{
if(lst.compareTo(rt)==-)
return lst;
else return rt;
}
lst=rt;
rt=nxt;
}
}
}

二分开根的,这个可以过这个题

Game of Taking Stones

HDU - 5973

    static BigDecimal cal(int x)
{
BigDecimal tmp=BigDecimal.valueOf();
BigDecimal xx=BigDecimal.valueOf(x);
BigDecimal l=BigDecimal.ZERO;
BigDecimal r=BigDecimal.valueOf(x);
for(int i=;i<;i++)
{
BigDecimal mid=(l.add(r)).divide(tmp);
if(mid.multiply(mid).compareTo(xx)==)
{
r=mid;
}
else
{
l=mid;
}
}
return l;
}

K. Transport Ship

There are NN different kinds of transport ships on the port. The i^{th}ith kind of ship can carry the weight of V[i]V[i] and the number of the i^{th}ith kind of ship is 2^{C[i]} - 12C[i]−1. How many different schemes there are if you want to use these ships to transport cargo with a total weight of SS?

It is required that each ship must be full-filled. Two schemes are considered to be the same if they use the same kinds of ships and the same number for each kind.

Input

The first line contains an integer T(1 \le T \le 20)T(1≤T≤20), which is the number of test cases.

For each test case:

The first line contains two integers: N(1 \le N \le 20), Q(1 \le Q \le 10000)N(1≤N≤20),Q(1≤Q≤10000), representing the number of kinds of ships and the number of queries.

For the next NN lines, each line contains two integers: V[i](1 \le V[i] \le 20), C[i](1 \le C[i] \le 20)V[i](1≤V[i]≤20),C[i](1≤C[i]≤20), representing the weight the i^{th}ith kind of ship can carry, and the number of the i^{th}ithkind of ship is 2^{C[i]} - 12C[i]−1.

For the next QQ lines, each line contains a single integer: S(1 \le S \le 10000)S(1≤S≤10000), representing the queried weight.

Output

For each query, output one line containing a single integer which represents the number of schemes for arranging ships. Since the answer may be very large, output the answer modulo 10000000071000000007.

样例输入复制

1
1 2
2 1
1
2

样例输出复制

0
1

题目来源

ACM-ICPC 2018 焦作赛区网络预赛

完全背包,顺便计数就好了

#include <bits/stdc++.h>
using namespace std;
const int MD=1e9+;
int dp[],v[],c[];
void pack1(int v)
{
for(int i=;i>=v;i--)
dp[i]+=dp[i-v],dp[i]%=MD;
}
void pack2(int v)
{
for(int i=v;i<=;i++)
dp[i]+=dp[i-v],dp[i]%=MD;
}
void pack3(int v,int num)
{
if(v*num>=)
{
pack2(v);
return;
}
int k=;
while(k<num)
{
pack1(k*v);
num-=k;
k<<=;
}
pack1(num*v);
}
int main()
{
int T,n,q,s;
scanf("%d",&T);
while(T--)
{
memset(dp,,sizeof dp);
scanf("%d%d",&n,&q);
for(int i=;i<n;i++)
scanf("%d%d",&v[i],&c[i]),c[i]=(<<c[i])-;
dp[]=;
for(int i=;i<n;i++)
pack3(v[i],c[i]);
while(q--)
{
scanf("%d",&s);
printf("%d\n",dp[s]);
}
}
return ;
}

L. Poor God Water

God Water likes to eat meat, fish and chocolate very much, but unfortunately, the doctor tells him that some sequence of eating will make them poisonous.

Every hour, God Water will eat one kind of food among meat, fish and chocolate. If there are 33 continuous hours when he eats only one kind of food, he will be unhappy. Besides, if there are 33continuous hours when he eats all kinds of those, with chocolate at the middle hour, it will be dangerous. Moreover, if there are 33 continuous hours when he eats meat or fish at the middle hour, with chocolate at other two hours, it will also be dangerous.

Now, you are the doctor. Can you find out how many different kinds of diet that can make God Water happy and safe during NN hours? Two kinds of diet are considered the same if they share the same kind of food at the same hour. The answer may be very large, so you only need to give out the answer module 10000000071000000007.

Input

The fist line puts an integer TT that shows the number of test cases. (T \le 1000T≤1000)

Each of the next TT lines contains an integer NN that shows the number of hours. (1 \le N \le 10^{10}1≤N≤1010)

Output

For each test case, output a single line containing the answer.

样例输入复制

3
3
4
15

样例输出复制

20
46
435170

题目来源

ACM-ICPC 2018 焦作赛区网络预赛

矩阵快速幂,比较难找到公式,所以暴力打表,直接dls模板过题

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define SZ(x) ((int)(x).size())
#define pb push_back
typedef vector<int> VI;
typedef long long ll;
const ll mod=;
ll powmod(ll a,ll b)
{
ll res=;
a%=mod;
assert(b>=);
for(; b; b>>=)
{
if(b&)res=res*a%mod;
a=a*a%mod;
}
return res;
} int t;
namespace linear_seq
{
const int N=;
ll res[N],base[N],_c[N],_md[N]; vector<int> Md;
void mul(ll *a,ll *b,int k)
{
rep(i,,k+k) _c[i]=;
rep(i,,k) if (a[i]) rep(j,,k) _c[i+j]=(_c[i+j]+a[i]*b[j])%mod;
for (int i=k+k-; i>=k; i--) if (_c[i])
rep(j,,SZ(Md)) _c[i-k+Md[j]]=(_c[i-k+Md[j]]-_c[i]*_md[Md[j]])%mod;
rep(i,,k) a[i]=_c[i];
}
int solve(ll n,VI a,VI b) // a 系数 b 初值 b[n+1]=a[0]*b[n]+...
{
// printf("%d\n",SZ(b));
ll ans=,pnt=;
int k=SZ(a);
assert(SZ(a)==SZ(b));
rep(i,,k) _md[k--i]=-a[i];
_md[k]=;
Md.clear();
rep(i,,k) if (_md[i]!=) Md.push_back(i);
rep(i,,k) res[i]=base[i]=;
res[]=;
while ((1ll<<pnt)<=n) pnt++;
for (int p=pnt; p>=; p--)
{
mul(res,res,k);
if ((n>>p)&)
{
for(int i=k-; i>=; i--) res[i+]=res[i];
res[]=;
rep(j,,SZ(Md)) res[Md[j]]=(res[Md[j]]-res[k]*_md[Md[j]])%mod;
}
}
rep(i,,k) ans=(ans+res[i]*b[i])%mod;
if (ans<) ans+=mod;
return ans;
}
VI BM(VI s)
{
VI C(,),B(,);
int L=,m=,b=;
rep(n,,SZ(s))
{
ll d=;
rep(i,,L+) d=(d+(ll)C[i]*s[n-i])%mod;
if (d==) ++m;
else if (*L<=n)
{
VI T=C;
ll c=mod-d*powmod(b,mod-)%mod;
while (SZ(C)<SZ(B)+m) C.pb();
rep(i,,SZ(B)) C[i+m]=(C[i+m]+c*B[i])%mod;
L=n+-L;
B=T;
b=d;
m=;
}
else
{
ll c=mod-d*powmod(b,mod-)%mod;
while (SZ(C)<SZ(B)+m) C.pb();
rep(i,,SZ(B)) C[i+m]=(C[i+m]+c*B[i])%mod;
++m;
}
}
return C;
}
int gao(VI a,ll n)
{
VI c=BM(a);
c.erase(c.begin());
rep(i,,SZ(c)) c[i]=(mod-c[i])%mod;
return solve(n,c,VI(a.begin(),a.begin()+SZ(c)));
}
}; int main()
{
for(scanf("%d",&t); t; t--)
{
ll n;
scanf("%lld",&n);
printf("%d\n",linear_seq::gao(VI{,,,,,,,,,,,,},n-));
}
return ;
}
 

ACM-ICPC 2018 焦作赛区网络预赛的更多相关文章

  1. ACM-ICPC 2018 焦作赛区网络预赛- G:Give Candies(费马小定理,快速幂)

    There are N children in kindergarten. Miss Li bought them NNN candies. To make the process more inte ...

  2. ACM-ICPC 2018 焦作赛区网络预赛- L:Poor God Water(BM模板/矩阵快速幂)

    God Water likes to eat meat, fish and chocolate very much, but unfortunately, the doctor tells him t ...

  3. ACM-ICPC 2018 焦作赛区网络预赛J题 Participate in E-sports

    Jessie and Justin want to participate in e-sports. E-sports contain many games, but they don't know ...

  4. ACM-ICPC 2018 焦作赛区网络预赛 K题 Transport Ship

    There are NN different kinds of transport ships on the port. The i^{th}ith kind of ship can carry th ...

  5. ACM-ICPC 2018 焦作赛区网络预赛 L 题 Poor God Water

    God Water likes to eat meat, fish and chocolate very much, but unfortunately, the doctor tells him t ...

  6. ACM-ICPC 2018 焦作赛区网络预赛 I题 Save the Room

    Bob is a sorcerer. He lives in a cuboid room which has a length of AA, a width of BB and a height of ...

  7. ACM-ICPC 2018 焦作赛区网络预赛 H题 String and Times(SAM)

    Now you have a string consists of uppercase letters, two integers AA and BB. We call a substring won ...

  8. ACM-ICPC 2018 焦作赛区网络预赛 G题 Give Candies

    There are NN children in kindergarten. Miss Li bought them NN candies. To make the process more inte ...

  9. ACM-ICPC 2018 焦作赛区网络预赛 B题 Mathematical Curse

    A prince of the Science Continent was imprisoned in a castle because of his contempt for mathematics ...

随机推荐

  1. ABAP和Hybris的源代码生成工具

    ABAP 有两种方式,一种是ABAP Code Composer, 细节可以查看我的博客Step by Step to generate ABAP code automatically using C ...

  2. 问题 F: 等比数列

    问题 F: 等比数列 时间限制: 1 Sec  内存限制: 64 MB提交: 2699  解决: 1214[提交][状态][讨论版][命题人:外部导入] 题目描述 已知q与n,求等比数列之和: 1+q ...

  3. 2018.6.5 Oracle plsql编程 游标的使用

    --3.查询10部门所有员工的姓名.(ref游标实现) 动态游标 declare --创建一种游标类型 type type_cursor is ref cursor; --声明变量指定游标类型 v_c ...

  4. 【算法】Fibonacci(斐波那契数列)相关问题

    一.列出Fibonacci数列的前N个数 using System; using System.Collections.Generic; using System.Linq; using System ...

  5. centos下 将(jgp、png)图片转换成webp格式

    由于项目要求需要将jpg.png类型的图片  转换成webp格式,最开始使用了php gd类库里 imagewebp 方法实现,结果发现转换成的webp格式文件会偶尔出现空白内容的情况.像创建了一个透 ...

  6. 1- vue django restful framework 打造生鲜超市

    Vue+Django REST framework实战 使用Python3.6与Django2.0.2(Django-rest-framework)以及前端vue开发的前后端分离的商城网站 项目支持支 ...

  7. [转载]Failed to read session data On PHP 7.1

    从php5.6升级php7.1,报错 Warning: session_start(): Failed to read session data: user (path: ) Warning: ses ...

  8. javascript 计算倒计时

    function timeDown(second) { var month = '', day = '', hour = '', minute = ''; if (second >= 86400 ...

  9. Codeforces Round #460 (Div. 2)-D. Substring

    D. Substring time limit per test3 seconds memory limit per test256 megabytes Problem Description You ...

  10. Nodejs-文件流

    1.什么是流? 流是程序输入输出的一个连续的字节序列. 有文件流,网络流,设备(例如鼠标,键盘,磁盘,调制解调器和打印机)的输入输出都是用流来处理的. 任何数据的最根本表现形式都是二进制. 读取文件 ...