Friend-Graph

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 6514    Accepted Submission(s): 1610

Problem Description
It is well known that small groups are not conducive of the development of a team. Therefore, there shouldn’t be any small groups in a good team.
In a team with n members,if there are three or more members are not friends with each other or there are three or more members who are friends with each other. The team meeting the above conditions can be called a bad team.Otherwise,the team is a good team.
A company is going to make an assessment of each team in this company. We have known the team with n members and all the friend relationship among these n individuals. Please judge whether it is a good team.
 
Input
The first line of the input gives the number of test cases T; T test cases follow.(T<=15)
The first line od each case should contain one integers n, representing the number of people of the team.(n≤3000)

Then there are n-1 rows. The ith row should contain n-i numbers, in which number aij represents the relationship between member i and member j+i. 0 means these two individuals are not friends. 1 means these two individuals are friends.

 
Output
Please output ”Great Team!” if this team is a good team, otherwise please output “Bad Team!”.
 
Sample Input
1
4
1 1 0
0 0
1
 
Sample Output
Great Team!
 

判断存不存在三元环,这个要拓扑排序跑一遍?emmm,wa

暴力判一下就好了,还得用bool

#include<stdio.h>
#include<string.h>
using namespace std;
bool a[][];
int n;
bool check()
{
int i,j,k;
for(i=; i<=n; i++)
{
for(j=i+; j<=n; j++)
{
if(a[i][j])
for(k=; k<=n; k++)
{
if(a[i][k]&&a[k][j])
{
return ;
}
}
}
}
return ;
}
int main()
{
int t,x,i,j,k,p,s;
scanf("%d",&t);
while(t--)
{
s=;
memset(a,false,sizeof(a));
scanf("%d",&n);
for(i=; i<=n; i++)
{
for(j=i+; j<=n; j++)
{
scanf("%d",&x);
if(x==)
a[i][j]=a[j][i]=true;
}
}
if(check())
printf("Bad Team!\n");
else printf("Great Team!\n");
}
return ;
}

CaoHaha's staff

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2089    Accepted Submission(s): 818

Problem Description
"You shall not pass!"
After shouted out that,the Force Staff appered in CaoHaha's hand.
As we all know,the Force Staff is a staff with infinity power.If you can use it skillful,it may help you to do whatever you want.
But now,his new owner,CaoHaha,is a sorcerers apprentice.He can only use that staff to send things to other place.
Today,Dreamwyy come to CaoHaha.Requesting him send a toy to his new girl friend.It was so far that Dreamwyy can only resort to CaoHaha.
The first step to send something is draw a Magic array on a Magic place.The magic place looks like a coordinate system,and each time you can draw a segments either on cell sides or on cell diagonals.In additional,you need 1 minutes to draw a segments.
If you want to send something ,you need to draw a Magic array which is not smaller than the that.You can make it any deformation,so what really matters is the size of the object.
CaoHaha want to help dreamwyy but his time is valuable(to learn to be just like you),so he want to draw least segments.However,because of his bad math,he needs your help.
 
Input
The first line contains one integer T(T<=300).The number of toys.
Then T lines each contains one intetger S.The size of the toy(N<=1e9).
 
Output
Out put T integer in each line ,the least time CaoHaha can send the toy.
 
Sample Input
5
1
2
3
4
5
 
Sample Output
4 4 6 6 7

就是在网格纸画面积为n需要的最小的棍子数,你的边可以是√2或者1,学姐莽了一发过了

我是躺赢的

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
double f[];
int main()
{
__int64 t,n,i,j,p,q,l;
for(i=;;i+=)
{
p=i/;
q=p/;
p=p-q;
if(p<q)
swap(p,q);
f[i]=p*q*;
f[i+]=f[i]+p-0.5;
if(f[i]>=)
break;
l=i;
//printf("%d..%d\n",i,f[i]);
}
//printf("%I64d\n",l);
scanf("%I64d",&t);
while(t--)
{
scanf("%I64d",&n);
for(i=;i<l;i++)
if(f[i]>=n)break;
printf("%I64d\n",i);
}
}

Palindrome Function

Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 256000/256000 K (Java/Others)
Total Submission(s): 1141    Accepted Submission(s): 390

Problem Description
As we all know,a palindrome number is the number which reads the same backward as forward,such as 666 or 747.Some numbers are not the palindrome numbers in decimal form,but in other base,they may become the palindrome number.Like 288,it’s not a palindrome number under 10-base.But if we convert it to 17-base number,it’s GG,which becomes a palindrome number.So we define an interesting function f(n,k) as follow:
f(n,k)=k if n is a palindrome number under k-base.
Otherwise f(n,k)=1.
Now given you 4 integers L,R,l,r,you need to caluclate the mathematics expression ∑Ri=L∑rj=lf(i,j) .
When representing the k-base(k>10) number,we need to use A to represent 10,B to represent 11,C to repesent 12 and so on.The biggest number is Z(35),so we only discuss about the situation at most 36-base number.
 
Input
The first line consists of an integer T,which denotes the number of test cases.
In the following T lines,each line consists of 4 integers L,R,l,r.
(1≤T≤105,1≤L≤R≤109,2≤l≤r≤36)
 
Output
For each test case, output the answer in the form of “Case #i: ans” in a seperate line.
 
Sample Input
3
1 1 2 36
1 982180 10 10
496690841 524639270 5 20
 
Sample Output
Case #1: 665
Case #2: 1000000
Case #3: 447525746
 

据说是原题?可是我怎么会啊,这个还卡memset,要记忆化一下,学长过的,萌新瑟瑟发抖

#include<stdio.h>
#include<string.h>
#define ll __int64
int bits[];
int dp[][][];
int dfs(int len,int l,int r,bool flag,bool ok,int b)
{
if(r > l) return !flag || (flag && ok);
if(!flag && ~dp[len][l][b+]) return dp[len][l][b+];
int end = flag ? bits[l] : b;
int res = ;
for(int i=;i<=end;i++)
{
if(l == len && i == ) continue;
bool g = ok;
if(ok) g = bits[r] >= i;
else g = bits[r] > i;
res += dfs(len,l-,r+,flag&&(i==end),g,b);
}
return flag ? res : dp[len][l][b+] = res;
}
int solve(int x,int b)
{
int tt = x;
int cnt = ;
while(tt > )
{
bits[++cnt] = tt % b;
tt /= b;
}
int ret = ;
for(int i=cnt;i>=;i--)
ret += dfs(i,i,,i==cnt,true,b-);
return ret;
}
int main()
{
int T;
int C = ;
scanf("%d",&T);
memset(dp,-,sizeof(dp));
while(T--)
{
int l,r,m,n;
__int64 ans=;
scanf("%d%d%d%d",&l,&r,&m,&n);
for(int i=m;i<=n;i++){ int sum=r-l+;
int sum1=solve(r,i)-solve(l-,i);
ans+=sum-sum1+sum1*i;
}
printf("Case #%d: %I64d\n",C++,ans);
}
return ;
}
 
Today is the birthday of SF,so VS gives two strings S1,S2 to SF as a present,which have a big secret.SF is interested in this secret and ask VS how to get it.There are the things that VS tell: 
  Suffix(S2,i) = S2[i...len].Ni is the times that Suffix(S2,i) occurs in S1 and Li is the length of Suffix(S2,i).Then the secret is the sum of the product of Ni and Li. 
  Now SF wants you to help him find the secret.The answer may be very large, so the answer should mod 1000000007.

InputInput contains multiple cases. 
  The first line contains an integer T,the number of cases.Then following T cases. 
  Each test case contains two lines.The first line contains a string S1.The second line contains a string S2. 
  1<=T<=10.1<=|S1|,|S2|<=1e6.S1 and S2 only consist of lowercase ,uppercase letter.OutputFor each test case,output a single line containing a integer,the answer of test case. 
  The answer may be very large, so the answer should mod 1e9+7.Sample Input

2
aaaaa
aa
abababab
aba

Sample Output

13
19

Hint

case 2:
Suffix(S2,1) = "aba",
Suffix(S2,2) = "ba",
Suffix(S2,3) = "a".
N1 = 3,
N2 = 3,
N3 = 4.
L1 = 3,
L2 = 2,
L3 = 1.
ans = (3*3+3*2+4*1)%1000000007.

知道做法做不出来怎么办啊,这个KMP(看毛片)要怎么魔改啊,懵懵懵,还不是自己不了解KMP

#include <bits/stdc++.h>
using namespace std;
const int N=;
char s[N],t[N];
int nex[N],sum[N];
const int MD=1e9+;
__int64 ans;
__int64 getnum(__int64 x){
return (x+)*x/;
}
void pre(char *p)
{
int i,m,j;
m=strlen(p);
nex[]=nex[]=;
for(int i=; i<m; i++)
{
j=nex[i];
while(j&&p[i]!=p[j])j=nex[j];
nex[i+]=p[i]==p[j]?j+:;
}
}
void kmp(char *t, char *p)
{
int j=;
int n=strlen(t);
for(int i=; i<n; i++)
{
while(j&&p[j]!=t[i])
{
j=nex[j];
}
if(p[j]==t[i])
{
j++;
ans=(ans+j)%MD;
}
ans=(ans+getnum(nex[j]))%MD;
}
}
int main()
{
int T;
scanf("%d",&T);
getchar();
while(T--)
{
ans=;
scanf("%s",s);
scanf("%s",t);
reverse(s,s+strlen(s));
reverse(t,t+strlen(t));
pre(t);
kmp(s,t);
printf("%I64d\n",ans);
}
return ;
}

以下代码为昂老师写,这个思路感觉好

#include <bits/stdc++.h>
using namespace std;
const int N = ;
const int Q = 1e9 + ;
char s[N], t[N];
int n, m, f[N], cnt[N];
int main()
{
int T;
scanf("%d", &T);
while (T --)
{
scanf("%s%s", t, s);
n = strlen(t);
m = strlen(s);
reverse(s, s + m);
reverse(t, t + n);
f[] = f[] = ;
for (int i = ; i < m ; ++ i)
{
int j = f[i];
while (j && s[i] != s[j])
j = f[j];
f[i + ] = s[i] == s[j] ? j + : ;
}
memset(cnt, , sizeof(int) * (m + ));
for (int i = , j = ; i < n ; ++ i)
{
while (j && t[i] != s[j])
j = f[j];
j += (t[i] == s[j]);
++ cnt[j];
}
for (int i = m ; i > ; -- i)
{
cnt[f[i]] += cnt[i];
}
int res = ;
for (int i = ; i <= m ; ++ i)
{
res += (long long)cnt[i] * i % Q;
res %= Q;
}
cout << res << endl;
}
return ;
}

菜鸡的2017CPPC网络赛的更多相关文章

  1. 2017 ACM-ICPC 亚洲区(西安赛区)网络赛 F. Trig Function(切比雪夫多项式+乘法逆元)

    题目链接:哈哈哈哈哈哈 _(:з」∠)_ _(:з」∠)_ _(:з」∠)_ _(:з」∠)_ _(:з」∠)_ 哈哈哈哈哈哈,从9月16日打了这个题之后就一直在补这道题,今天终于a了,哈哈哈哈哈哈. ...

  2. ACM菜鸡退役帖——ACM究竟给了我什么?

    这个ACM退役帖,诸多原因(一言难尽...),终于决定在我大三下学期开始的时候写出来.下面说两个重要的原因. 其一是觉得菜鸡的ACM之旅没人会看的,但是新学期开始了,总结一下,只为了更好的出发吧. 其 ...

  3. (未完结)“文远知行杯”GDET第十四届竞赛(网络赛共10题,仅整理出6题)

    刚开学没多久就打了一个网络赛,通过这次网络赛我是发现我是真的菜... 放假前校赛的排名让我有些自满,寒假丝毫没有接触ACM,一直沉迷于Steam,这个真的值得好好反省. 虽然现在大一课有点多,在学校也 ...

  4. 2012年长春网络赛(hdu命题)

    为迎接9月14号hdu命题的长春网络赛 ACM弱校的弱菜,苦逼的在机房(感谢有你)呻吟几声: 1.对于本次网络赛,本校一共6名正式队员,训练靠的是完全的自主学习意识 2.对于网络赛的群殴模式,想竞争现 ...

  5. 计蒜客 17119.Trig Function-切比雪夫多项式+乘法逆元 (2017 ACM-ICPC 亚洲区(西安赛区)网络赛 F)

    哈哈哈哈哈哈哈哈哈哈哈哈,终于把这道题补出来了_(:з」∠)_ 来写题解啦. _(:з」∠)_ _(:з」∠)_ _(:з」∠)_ _(:з」∠)_ _(:з」∠)_ 哈哈哈哈哈哈,从9月16日打了这 ...

  6. 2019 ICPC南昌邀请赛网络赛比赛过程及题解

    解题过程 中午吃饭比较晚,到机房lfw开始发各队的账号密码,byf开始读D题,shl电脑卡的要死,启动中...然后听到谁说A题过了好多,然后shl让blf读A题,A题blf一下就A了.然后lfw读完M ...

  7. 南昌网络赛C.Angry FFF Party

    南昌网络赛C.Angry FFF Party Describe In ACM labs, there are only few members who have girlfriends. And th ...

  8. 2019杭电多校&CCPC网络赛&大一总结

    多校结束了, 网络赛结束了.发现自己还是太菜了,多校基本就是爆零和签到徘徊,第一次打这种高强度的比赛, 全英文,知识点又很广,充分暴露了自己菜的事实,发现数学还是很重要的.还是要多刷题,少玩游戏. 网 ...

  9. Html菜鸡大杂烩

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

随机推荐

  1. vue使用echarts可视化图形插件

    1.安装echarts:  cnpm/npm i echarts -S 2.main.js中   import echarts from 'echart'    Vue.prototype.$echa ...

  2. Servlet和JSP之JSTL学习

    JSTL JSTL就是JSP标准标签库(JavaServer Pages Standard Tag Library, JSTL)是一个定制标签库的集合,用来解决像遍历Map或集合.条件测试.XML处理 ...

  3. 一个具体的例子学习Java volatile关键字

    相信大多数Java程序员都学习过volatile这个关键字的用法.百度百科上对volatile的定义: volatile是一个类型修饰符(type specifier),被设计用来修饰被不同线程访问和 ...

  4. iOS上架问题解决

    dns问题 http://iphone.91.com/tutorial/syjc/140509/21686339.html 网络问题 手机4g开wifi,上传提交多次 时间问题 东八区下午6点上架成功 ...

  5. (六)使用Docker镜像(下)

    1. 创建镜像 创建镜像的方法有三种: 基于已有镜像的容器创建 基于本地模板导入 基于Dockerfile创建 1.1 基于已有镜像的容器创建 该方法主要是使用docker commit命令,其格式 ...

  6. jquery插件serializeFormToObject

    $.fn.serializeObject = function() { var o = {}; var a = this.serializeArray(); $.each(a, function() ...

  7. websphere7.0异常:SRVE0255E: 尚未定义要处理 /wcm 的 Web 组/虚拟主机

    websphere7.0错误:SRVE0255E: 尚未定义要处理 /wcm 的 Web 组/虚拟主机. SRVE0255E: 尚未定义要处理 /wcm 的 Web 组/虚拟主机.SRVE0255E: ...

  8. Bootstrap响应式布局(1)

    <!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...

  9. How To:Linux下如何通过命令检查网卡是否插上网线

    主要工具为ethtool来检查,主要关注的字段为"Link detected",注意如下的输出,其中em4实际物理上并未插上网线,而em1是插上网线的: # ethtool em4 ...

  10. CONTEST1001 题解

    PROBLEM A 分析 这个题属于非常基础的输出问题,一般来说见到这种题可以直接复制粘贴即可. 讲解 没有什么详细说明的直接复制粘贴即可.这样不容易出错. 代码 #include <stdio ...