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

每天都有新的难过

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. linux 命令——36 diff(转)

    diff命令是 linux上非常重要的工具,用于比较文件的内容,特别是比较两个版本不同的文件以找到改动的地方.diff在命令行中打印每一个行的改动.最新版本的diff还支持二进制文件.diff程序的输 ...

  2. java的图形界面初学惯用

    1.单一界面的创建 public void mainFrame() { HashMap<String, Component> views = new HashMap<String, ...

  3. 2018.5.30 Oracle数据库PLSQL编程---游标的使用

    显示游标的步骤 /* 显示游标处理步骤 1.声明游标 语法结构:cursor 游标名称 is SQL 语句; 2.打开游标 语法结构:open游标名称; 3.提取数据 语法结构:fetch 4.关闭游 ...

  4. java 学习集锦

    java学习系列 http://www.cnblogs.com/skywang12345/category/455711.html

  5. python_70_内置函数2

    #hex() 转16进制 oct()转8进制 print(hex(255)) print(oct(10)) #id() 返回内存地址 print(id('a')) ''' isinstance(obj ...

  6. CUDA高性能编程中文实战11章例子中多设备的例子编译提示问题

    提示的问题如下: error : argument of type "void *(*)(void *)" is incompatible with parameter of ty ...

  7. 记录一下CSS outline-width 属性

    outline(轮廓)是绘制于元素周围的一条线,位于边框边缘的外围. outline-width指定轮廓的宽度. 注意: 请始终在outline-width属性之前声明outline-style属性. ...

  8. JS起源

    一.初始JavaScript Mosaic是互联网历史上第一个普遍使用和显示图片的浏览器1993年问世. 后来由于商标权转让,原本的开发团队又开发了Netscape Navigetor网景浏览器,也是 ...

  9. Spring Cloud学习介绍

    最近在学spring cloud, 整理了下 简单知识要求: 1.要了解springboot 2.了解分布式架构 3.了解微服务 4.了解springcloud是做什么的 带着这些,初学者 就至少有个 ...

  10. 转载:jsonp详解

    json相信大家都用的多,jsonp我就一直没有机会用到,但也经常看到,只知道是“用来跨域的”,一直不知道具体是个什么东西.今天总算搞明白了.下面一步步来搞清楚jsonp是个什么玩意. 同源策略 首先 ...