这次百度之星,我做出来了7道,另外有2题的答案也被我找到了,还有一道F题希望有的人给我留下言吧,我想学习下。下面是我的答案,大多是用C++,也有几道是用Java的,代码里的一些css的东西请去掉,是csdn上加上去的。这次初赛可以说是不难的,像我这样的新手都能做出7道。不过,有些题目要好好考虑错误情况。F题,有人说百度翻译的不到位,这是别人告诉我的原文,http://162.105.81.212:8080/problem?id=3814。
#include
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
n=n+m;
cout<
#include
using namespace std;
int main()
{
int n,m,a,s;
cin>>n;
while(n--)
{
cin>>m;
s=1-m;
while(m--)
{
cin>>a;
s+=a;
}
cout<
#include
#include
using namespace std;
int main()
{
int n=12;
double s=0,m;
while(n--)
{
cin>>m;
s=s+m;
}
s=s/12;
cout<
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int n, m;
Scanner scanner = new Scanner(System.in);
String ss = scanner.nextLine();
n = Integer.parseInt(ss);
while (n-- > 0) {
String temp = scanner.nextLine();
String a[] = temp.split(":");
if (!a[1].equals("00")) {
System.out.println(0);
} else {
m = Integer.parseInt(a[0]);
m = m + 12;
if (m > 24)
m -= 24;
System.out.println(m);
}
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String ss;
while ((ss = scanner.nextLine()) != null) {
int index1 = 0;
boolean index2;
index1 = ss.indexOf("_");
index2 = ss.matches(".*[A-Z].*");
if (index1 != -1 && !index2) {
if (ss.charAt(0) == '_' || ss.charAt(ss.length() - 1) == '_') {
System.out.println("Error!");
} else {
boolean t = true;
String temp[] = ss.split("_");
String result = temp[0];
for (int a = 1; a < temp.length; a++) {
if (temp[a].equals("")) {
t = false;
break;
}
// System.out.println(temp[a]+"KKK");
result += temp[a].substring(0, 1).toUpperCase()
+ temp[a].substring(1);
}
if (t)
System.out.println(result);
else
System.out.println("Error!");
}
} else if (index1 == -1 && index2) {
boolean tt = true;
String result = "";
int kk = 0;
for (int i = 0; i < ss.length(); i++) {
if (ss.charAt(0) >= 'A' && ss.charAt(0) <= 'Z') {
tt = false;
break;
}
if (ss.charAt(i) >= 'A' && ss.charAt(i) <= 'Z') {
result += ss.substring(kk, i).toLowerCase() + "_";
kk = i;
}
if (i == ss.length() - 1)
result += ss.substring(kk).toLowerCase();
}
if (tt)
System.out.println(result);
else
System.out.println("Error!");
} else if (index1 == -1 && !index2) {
System.out.println(ss);
} else
System.out.println("Error!");
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String ss;
while((ss = scanner.nextLine())!=null)
{
System.out.println(ss);
}
}
}
#include
#include
#include
#include
using namespace std;
const int maxn=100010;
const int inf=5000000;
int w[maxn],wa[maxn],wb[maxn],wv[maxn];
int sa[maxn],rank[maxn],height[maxn];
int a[maxn],f[maxn][20],n,ft[maxn],len[maxn];
int num;
char s[maxn];
int cmp(int *r,int a,int b,int l)
{
return r[a]==r[b]&&r[a+l]==r[b+l];
}
void da(int *r,int *sa,int n,int m)
{
int i,j,p,*x=wa,*y=wb,*t;
for (i=0; i=0; i--) sa[--w[x[i]]]=i;
for (p=1,j=1; p=j) y[p++]=sa[i]-j;
for (i=0; i=0; i--) sa[--w[wv[i]]]=y[i];
for (t=x,x=y,y=t,x[sa[0]]=0,p=1,i=1; iy)
{
int t=x;
x=y;
y=t;
}
x++;
int t=ft[y-x+1];
return nmin(f[x][t],f[y-(1<=0&&k%l!=0)
if (lcp(t,t+l)>=k) r++;
if (r>max)
{
num=0;
len[++num]=l;
max=r;
}
else
if(r==max)
{
len[++num]=l;
}
//printf("l=%d r=%d i=%d i+l=%d/n",l,r,i,i+l);
}
// printf("%d/n",max);
int start,l;
for(int i=1;i=(max-1)*tl)
{
start=ts;
l=tl*max;
i=n;
break;
}
}
}
printf("Case %d: ", cas++);
for (int i = 0; i < l; i++) printf("%c", s[start+ i]);
cout<
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define INT_MAX 2147483647;
using namespace std;
int main()
{
int n,m,a,b,s1,i,min=INT_MAX;
cin>>n>>m;
while(m--)
{
cin>>a>>b;
i=b*n/(a+b);
s1=a*(i+1)-b*(n-i-1);
if(s1>0&&s1