2010 ACM-ICPC SEERC

http://codeforces.com/gym/101464/

过了5题

J: solved by ?

/*
  ID: oodt
  PROG:
  LANG:C++
*/
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<cassert>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<set>

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 pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxx=10005;
const int INF = 0x3f3f3f3f;
int n,m,k;
int a[maxx];
int vis[maxx];
int ans = 0,cnt = 0,pos = 0;
int l = 0,r = 0;


int main()
{
#ifdef LOCAL
//    freopen("","r",stdin);
#endif
    freopen("j.in","r",stdin);
    while(~scanf("%d%d",&m,&n))
    {
        printf("%d\n",n/(m+1));
    }
    return 0;
}

E:  solved by ?

/*
  ID: oodt
  PROG:
  LANG:C++
*/
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<cassert>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<set>

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 pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxx=10005;
const int INF = 0x3f3f3f3f;
int n,m,k;
int a[maxx];
int vis[maxx];
int ans = 0,cnt = 0,pos = 0;
int l = 0,r = 0;


int main()
{
#ifdef LOCAL
//    freopen("","r",stdin);
#endif
    freopen("e.in","r",stdin);
    int n;
    int i;
    double covermax;
    int ans;
    while(scanf("%d",&n)!=EOF)
    {
        ans=0;
        double x;
        for(i=1;i<=n;i++)
        {
            scanf("%lf",&x);
            if(i==1){
                covermax=x+1;
                ans++;
                continue;
            }
            else
            {
                if(x<covermax)continue;
                else
                {
                    ans++;
                    covermax=x+1;
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

H: solved by ?

/*
  ID: oodt
  PROG:
  LANG:C++
*/
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<cassert>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<set>

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 pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxx=1005;
const int INF = 0x3f3f3f3f;
int n,m,k;
int b[maxx][maxx];
int c[maxx][maxx];
struct pp{
    ll h,l;
}a[maxx][maxx];
int vis[maxx];
int ans = 0,cnt = 0,pos = 0;
int l = 0,r = 0;


int main()
{
#ifdef LOCAL
//    freopen("","r",stdin);
#endif
     freopen("h.in","r",stdin);
    while(~scanf("%d",&n))
    {
        memset(a,0,sizeof(a));
        memset(c,0,sizeof(c));
        rep(i,1,n+1)
            rep(j,1,n+1)
                scanf("%d",&b[i][j]);
        rep(i,1,n+1){
            rep(j,1,n+1){
                a[i][j].h = a[i][j-1].h + b[i][j];
            }
        }
        rep(j,1,n+1){
            rep(i,1,n+1){
                a[i][j].l = a[i-1][j].l + b[i][j];
            }
        }
        rep(i,1,n+1){
            rep(j,1,n+1){
                if((a[i][j].l & 1) && (a[i][j].h&1))
                {
                    c[i][j] = 0;
                }
                if((a[i][j].l & 1) == 0 && (a[i][j].h & 1) == 0){
                        if(c[i][j-1] && c[i-1][j]) c[i][j] = 0;
                        else c[i][j] = 1;
                }
                if((a[i][j].l & 1) == 0 && (a[i][j].h & 1) == 1){
                    c[i][j] = (c[i][j-1] + 1) % 2;
                }
                if((a[i][j].h & 1) == 0 && (a[i][j].l & 1) == 1){
                    c[i][j] = (c[i-1][j] + 1) % 2;
                }
            }
        }
        if(c[n][n] == 1) printf("W\n");
        else printf("L\n");
    }
    return 0;
}

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')
            

猜你喜欢

转载自blog.csdn.net/njupt_lyy/article/details/81255876