http://codeforces.com/gym/101464/
过了5题
J: solved by ?
/*
ID: oodt
PROG:
LANG:C++
*/
#include
#include
#include
#include
#include
#include
#include
#include
E: solved by ?
/*
ID: oodt
PROG:
LANG:C++
*/
#include
#include
#include
#include
#include
#include
#include
#include
H: solved by ?
/*
ID: oodt
PROG:
LANG:C++
*/
#include
#include
#include
#include
#include
#include
#include
#include
A:高精度,用java写的,但是要求是读文件的操作啊,作为一个只会Biginteger的人,不会java的重定向,研究了将近2小时才研究出来, solved by lyy
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws FileNotFoundException {
Scanner in=new Scanner(new File("A.IN"));
//Scanner in=new Scanner(System.in);
BigInteger a[]=new BigInteger[105];
int n,m;
while (in.hasNext())
{
m=in.nextInt();
n=in.nextInt();
for (int i=1;i<=m;i++)
{
a[i]=BigInteger.ONE;
}
for (int i=1;i<=n;i++)
{
for (int j=1;j<=m;j++)
{
BigInteger x=in.nextBigInteger();
a[j]=a[j].multiply(x);
}
}
BigInteger ans=a[1];
int cnt=1;
for (int i=1;i<=m;i++)
{
if (ans.max(a[i]).equals(a[i]))
{
ans=ans.max(a[i]);
cnt=i;
}
}
System.out.println(cnt);
}
}
}
B:还是有高精度,而且还有表达式的处理,所以就偷个懒用python写,eval真的好用2333, solved by lyy
f=open('b.in','r')
data2=f.readlines()
w=''
for line in data2:
for s in line:
if s!=' ' and s!='\t' and s!='\r':
w=w+s
left=0
data=[]
z=''
for s in w:
if s=='\n':
if z!='' and z[-1]>='0'and z[-1]<='9':
data.append(z)
z='';
elif s=='(':
if left==0 and z!='':
data.append(z)
z=''
z=z+s
left+=1
elif s==')':
z=z+s
left-=1
if left==0 and z!='':
data.append(z)
z=''
else:
z=z+s
if (z!=''):
data.append(z)
for line in data:
#print(line)
s=line
s=s.replace('/','//')
l=len(s)
cnt=0;
for i in range(l):
if s[i]=='(':
cnt+=1
try:
r=0
for i in range(l):
if s[i]>='0' and s[i]<='9':
r+=1
else:
r=0
if r>90:
x=1//0
for step in range(cnt):
ss=''
l=len(s)
for i in range(l):
if s[i]=='(':
ss='('
elif s[i]==')':
ss=ss+')'
x=eval(ss)
if (x<0):
x=1//0
x=str(x)
if (len(x)>90):
x=1//0;
s=s.replace(ss,x)
#print(s)
break
else:
ss=ss+s[i]
print(s)
except:
print('Error')