周末训练笔记+2017 ACM/ICPC Asia Regional Qingdao+Xian Online(9.17)
来源:互联网 发布:mac mockup软件 编辑:程序博客网 时间:2024/05/21 19:32
昨天的西安赛区的就不说啥了,基本算是零鸭蛋,唯一过得一个“脑洞题”还是道听途说,最有戏的第二题,硬币概率那个,手算会算,代码敲出来,一直就达不到预期的精度,后来看题解,算法也有点问题,尴尬;青岛这场,前半程做的挺快,后半程就一直tle顺便看学长表演了,我们这边服务器崩溃了交了不知道结果,盲交,字符串的那个题,坑的我们不轻啊,调了半天的第一题结束后才知道wa了。
1001Apple
大体就是给出三个点的坐标,然后在给你一个点,问你这个点在不在前三个点组成的三角形确立的外接圆内
1003The Dominator of Strings
主导字符串就是其他串都是这个主导串的子串
给你n个字符串,求这个主导串
思路是很清晰的,主导最长的串,然后暴力查找解决,tle,我还一直以为是输入的问题,修改完输入还是tle,当时没找到更好的优化方法,到最后也没过
1008 Chinese Zodiac
生肖差几年
1011A Cubic number and A Cubic Number
n组询问,给你一个素数看看是否是两个数的立方之差
暴力解决可能会行不通,这个很快就找出了公式,每个数的立方差3*n*(n+1)+1 接下来暴力查找就行了
B. Coin
有一个不均匀的硬币,给出抛到正面的概率,一共k次,问你抛到正面向上的次数是偶数次的概率是多少mod1e+9+7 0也算是偶数
样例1: 2 1 1 0次 1/2*mod
样例2: 3 1 2 0+2次 (2/3*2/3+1/3+1/3)*mod
C. Sum
给出一个x,求k*x的每位数字相加可以被233整除,
脑洞最大的一个题,竟然还有通解,还有好几种,
1:直接输出233个9
3:直接输出1000000233次最后再加个1
Apple
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 0 Accepted Submission(s): 0
In the first line of each case, there are eight integers
The absolute values of integers in input are less than or equal to
It is guaranteed that, any three of the four positions do not lie on a straight line.
3-2 0 0 -2 2 0 2 -2-2 0 0 -2 2 0 0 2-2 0 0 -2 2 0 1 1
AcceptedRejectedRejectedpackage 青岛网络赛;import java.util.Scanner;import java.math.BigDecimal;import java.math.BigInteger;public class Main { public static void main(String []args) { Scanner sc=new Scanner(System.in); int t; double s; t=sc.nextInt(); while(t>0) { s=sc.nextDouble(); BigDecimal x1 = new BigDecimal(Double.toString(s)); s=sc.nextDouble(); BigDecimal y1 = new BigDecimal(Double.toString(s)); s=sc.nextDouble(); BigDecimal x2 = new BigDecimal(Double.toString(s)); s=sc.nextDouble(); BigDecimal y2 = new BigDecimal(Double.toString(s)); s=sc.nextDouble(); BigDecimal x3 = new BigDecimal(Double.toString(s)); s=sc.nextDouble(); BigDecimal y3 = new BigDecimal(Double.toString(s)); s=sc.nextDouble(); BigDecimal x = new BigDecimal(Double.toString(s)); s=sc.nextDouble(); BigDecimal y = new BigDecimal(Double.toString(s)); BigDecimal i = new BigDecimal(Double.toString(2.0)); BigDecimal a=(x1.subtract(x2)); BigDecimal b=(y1.subtract(y2)); BigDecimal c=(x1.subtract(x3)); BigDecimal d=(y1.subtract(y3)); BigDecimal a1 = x1.multiply(x1); BigDecimal b1 = y1.multiply(y1); BigDecimal a2 = x2.multiply(x2); BigDecimal b2 = y2.multiply(y2); BigDecimal a3 = x3.multiply(x3); BigDecimal b3 = y3.multiply(y3); BigDecimal e = ((a1.subtract(a2)).add (b1.subtract(b2))).divide(i); BigDecimal f = ((a1.subtract(a3)).add (b1.subtract(b3))).divide(i); System.out.println(e+" "+f); BigDecimal det=(b.multiply(c)).subtract(a.multiply(d)); System.out.println(det); BigDecimal x0=((d.multiply(e)).subtract(b.multiply(f))).divide(det); BigDecimal y0=((a.multiply(f)).subtract(c.multiply(e))).divide(det); BigDecimal r1=(((x1.add(x0)).multiply(x1.add(x0))).add((y1.add(y0)).multiply(y1.add(y0)))); BigDecimal r2=(((x.add(x0)).multiply(x.add(x0))).add((y.add(y0)).multiply(y.add(y0)))); if(r2.compareTo(r1)==1) System.out.println("Accepted"); else System.out.println("Rejected"); t--; } }}
Chinese Zodiac
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 0 Accepted Submission(s): 0
Victoria is married to a younger man, but no one knows the real age difference between the couple. The good news is that she told us their Chinese Zodiac signs. Their years of birth in luner calendar is not the same. Here we can guess a very rough estimate of the minimum age difference between them.
If, for instance, the signs of Victoria and her husband are ox and rabbit respectively, the estimate should be
For each test case a line of two strings describes the signs of Victoria and her husband.
3ox roosterrooster oxdragon dragon
8412
#include<iostream>#include<cstdio>#include<cstring>#include<string.h>#include<stdio.h>using namespace std;int main() { char x[12][10]={"rat","ox","tiger","rabbit","dragon","snake","horse","sheep","monkey","rooster","dog","pig"}; char a[10],b[10]; int i,s1,s2,t; cin>>t; while(t--) { cin>>a>>b; if(strcmp(a,b)==0) { cout<<12<<endl; continue; } for(i=0;i<12;i++) { if(strcmp(a,x[i])==0) s1=i; if(strcmp(b,x[i])==0) s2=i; } if(s1<s2) cout<<(s1-s2)*-1<<endl; else cout<<12-s1+s2<<endl; } return 0; }
A Cubic number and A Cubic Number
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 0 Accepted Submission(s): 0
For each test case, a line contains a prime number
102357111317192329
NONONOYESNONONOYESNONO
#include<iostream>#include<stdio.h>#include<string.h>#include<cmath>using namespace std;/*long long prime[1000000];int vis[1000000];void find(){ int k=0; vis[0]=0; vis[1]=0; for(int i=2;i<=10000;i++) { if(vis[i]==1) { prime[k]=i; k++; for(int j=i;j<=10000;j+=i) vis[j]=0; } }}*//*void find3(){ long long temp=1; for(int i=2;i<100000;i++) { for() map[k]=i*i*i-temp; temp=i*i*i; k++; } }*/int main(){ //for(int i=0;i<1000000;i++) //vis[i]=1; //find(); //for(int i=0;i<20;i++) //{ // cout<<prime[i]<<endl; //} //find3(); int t; cin>>t; long long x; while(t--) { cin>>x; int flag=0; for(long long i=1;i<10000000;i++) { if((long long )(3*i*(i+1)+1)==x) { flag=1; break; } } if(flag==1) cout<<"YES"<<endl; else cout<<"NO"<<endl; } return 0; }
The Dominator of Strings
Time Limit: 3000/3000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 0 Accepted Submission(s): 0
For each test case, the first line contains an integer
Each of the following
The total length of strings in each case has the limit of
The limit is 30MB for the input file.
310youbetterworsericherpoorersicknesshealthdeathfaithfulnessyoubemyweddedwifebetterworsericherpoorersicknesshealthtilldeathdouspartandpledgeyoumyfaithfulness5abccdeabcdeabcdebcde3aaaaaaaaabaaaac
youbemyweddedwifebetterworsericherpoorersicknesshealthtilldeathdouspartandpledgeyoumyfaithfulnessabcdeNo
又学了一招
因为不知道Java里怎么快速去查找字符串里是否有另一个子字符串
c++种stl种的find() 我还以为肯定可以了
import java.io.*;public class Main { static String str[]=new String[100010]; public static void main(String[] args) throws IOException { BufferedReader bf=new BufferedReader(new InputStreamReader(System.in)); String t=bf.readLine(); int T=Integer.parseInt(t); while(T>0){ String nr=bf.readLine(); int n; n=Integer.parseInt(nr); String fstr=""; for(int i=0;i<n;i++){ str[i]=bf.readLine(); if(str[i].length()>fstr.length()) fstr=str[i]; } int flag=1; for(int i=0;i<n;i++){ if(!fstr.contains(str[i])){ flag=0;break; } } if(flag==1) System.out.println(fstr); else System.out.println("No"); T--; } }}
#include<iostream>#include<stdio.h>#include<string.h>#include<string>using namespace std;string map[100010];int n;int ma=0;int temp=0;void init(){ string s; scanf("%d",&n); for(int i=0;i<n;i++) { //cin>>map[i]; cin>>map[i]; //len[i]=map[i].size(); if(map[i].size()>ma) { ma=map[i].size(); temp=i; } }}int judge(string s1,string s2){ string::size_type idx; idx=s1.find(s2); if(idx == string::npos ) return 0; else return 1; }/*int judge(string s1,string s2){ int sum=0; for(int i=0;i<s1.size();i++) { sum=0; if(s2[0]==s1[i]) { for(int j=1;j<s2.size();j++) { if(s2[j]==s1[i+j]) { //cout<<s2[j]<<" "<<s1[i+j]<<endl; sum++; } } // cout<<sum+1<<endl; if(sum+1==s2.size()) return 1; } } return 0; }*/void solve(){ for(int i=0;i<n;i++) { if(judge(map[temp],map[i])==0) { cout<<"NO"<<endl; return ; } } cout<<map[temp]<<endl; }int main(){ int t; //string s1="youbemyweddedwifebetterworsericherpoorersicknesshealthtilldeathdouspartandpledgeyoumyfaithfulness"; //string s2="bemuylhlhlh"; //cout<<judge(s1,s2)<<endl; scanf("%d",&t); while(t--) { ma=0; temp=0; //memset(map,0,sizeof(map)); init(); solve(); } return 0; }
C. Sum
Define the function S(x) for x is a positive integer. S(x) equals to the sum of all digit of the decimal expression of x. Please find a positive integer k that S(k∗x)%233=0.
Input Format
First line an integer T, indicates the number of test cases (T≤100). Then Each line has a single integer x(1≤x≤1000000) indicates i-th test case.
Output Format
For each test case, print an integer in a single line indicates the answer. The length of the answer should not exceed 2000. If there are more than one answer, output anyone is ok.
样例输入
11
样例输出
89999999999999999999999999
#include<iostream>#include<stdio.h>using namespace std;int main(){ int T; cin >> T; while (T--){ int x; cin >> x; for(int i=0;i<232;i++) { cout << 1000000; } cout << 1 << endl; } return 0; }
B. Coin
Bob has a not even coin, every time he tosses the coin, the probability that the coin's front face up is pq(pq≤21).
The question is, when Bob tosses the coin k times, what's the probability that the frequency of the coin facing up is even number.
If the answer is YX, because the answer could be extremely large, you only need to print (X∗Y−1)mod(109+7).
Input Format
First line an integer T, indicates the number of test cases (T≤100).
Then Each line has 3 integer p,q,k(1≤p,q,k≤107) indicates the i-th test case.
Output Format
For each test case, print an integer in a single line indicates the answer.
样例输入
22 1 13 1 2
样例输出
500000004555555560
[1+(p-2q)^n*(p^n)^(mod-2)%mod]*2^(mod-2)%mod;
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
const long long mod=1000000007;
long long pow(long long p, long long n)
{
long long s=1;
while(n)
{
if(n&1)
s=(s*p)%mod;
n>>=1;
p=(p*p)%mod;
}
return s;
}
int main()
{
int t;
long long p,q,k;
cin>>t;
while(t--)
{
scanf("%lld%lld%lld",&p,&q,&k);
//cout<<pow(p-2*q,k)<<endl;
//cout<<pow(2,3)<<endl;
long long a=(((1+pow(p-2*q,k)*pow(pow(p,k),mod-2))%mod)*pow(2,mod-2))%mod;
cout<<a<<endl;
}
return 0;
}
- 周末训练笔记+2017 ACM/ICPC Asia Regional Qingdao+Xian Online(9.17)
- 周末训练笔记+2017 ACM/ICPC Asia Regional Shenyang Online(9.10)
- 2017 ACM/ICPC Asia Regional Qingdao Online
- 2017 ACM/ICPC Asia Regional Qingdao Online
- 2017 ACM/ICPC Asia Regional Qingdao Online
- 2017 ACM/ICPC Asia Regional Qingdao Online
- 2017 ACM/ICPC Asia Regional Qingdao Online 1011(数学知识)
- 2016 ACM/ICPC Asia Regional Qingdao Online比赛笔记
- 【2016 ACM/ICPC Asia Regional Qingdao Online】
- 2016 ACM/ICPC Asia Regional Qingdao Online
- 2016 ACM/ICPC Asia Regional Qingdao Online
- 2017 ACM/ICPC Asia Regional Qingdao Online--Chinese Zodiac
- 2017 ACM/ICPC Asia Regional Qingdao Online:1001 Apple
- 2017 ACM/ICPC Asia Regional Qingdao Online:1008 Chinese Zodiac
- HDu 6216 && 2017 ACM/ICPC Asia Regional Qingdao Online 1011
- 2017 ACM/ICPC Asia Regional Qingdao Online【solved:7 / 11】
- HDU-2017 ACM/ICPC Asia Regional Qingdao Online-1001-Apple
- 2017 ACM/ICPC Asia Regional Qingdao Online Brute Force Sorting
- 上台阶问题
- 2.16 数据存储
- LeetCode 11. Container With Most Water
- java.io.FileNotFoundException: (文件名、目录名或卷标语法不正确。)
- Text Reverse
- 周末训练笔记+2017 ACM/ICPC Asia Regional Qingdao+Xian Online(9.17)
- 度与弧度
- 2.17 数据库
- 2017年9月17日周记
- java打印实心菱形,空心菱形,for循环嵌套
- Mybatis笔记(持续更新)
- 算法--回文序列
- 题目60-谁获得了最高奖学金
- Hadoop2.x环境搭建1