UESTC 第七届ACM趣味程序设计竞赛第四场(正式赛)

Final Pan’s prime numbers
http://www.acm.uestc.edu.cn/#/problem/show/1272

#include 
#define INF 0x3f3f3f3f
#define eps 1e-6
typedef long long LL;
const double pi = acos(-1.0);
const double delta = 1e-9;
const long long mod = 1e9 + 7;
using namespace std;

int main()
{
    //freopen("int.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    LL n;
    scanf("%lld",&n);
    if(n > 6)
        puts("7");
    else
        puts("-1");
    return 0;
}

ZhangYu Speech
http://acm.uestc.edu.cn/#/problem/show/1269

#include 
#define INF 0x3f3f3f3f
#define eps 1e-6
typedef long long LL;
const double pi = acos(-1.0);
const double delta = 1e-9;
const long long mod = 1e9 + 7;
using namespace std;

int a[100005];
char s[100005];
int sum[100005];

int main()
{
    //freopen("int.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int m,n;
    scanf("%d %d",&m,&n);
    scanf("%s",s);
    for(int i = 1;i <= m;i++)
        a[i] = s[i - 1] - '0';
    int x;
    sum[1] = a[1];
    sum[0] = 0;
    for(int i = 1;i < m;i++)
        sum[i + 1] = sum[i] + a[i + 1];
    while(n--)
    {
        scanf("%d",&x);
        int ans = (x - 1) * a[x] - sum[x - 1];
        if(ans > 0)
            puts("Keep some distance from me");
        else if(ans == 0)
            puts("Next time");
        else
            puts("I agree");
    }
    return 0;
}

Search gold
http://acm.uestc.edu.cn/#/problem/show/1271

#include 
#define INF 0x3f3f3f3f
#define eps 1e-6
typedef long long LL;
const double pi = acos(-1.0);
const double delta = 1e-9;
const long long mod = 1e9 + 7;
using namespace std;

int X[] = {1,0,1,2};
int Y[] = {0,1,2,1};
int a[1005][1005];
int dp[1005][1005];
int m,n;


int check(int x,int y)
{
    if(x < 1 || x > n)
        return 0;
    if(y < 1 || y > m)
        return 0;
    return 1;
}

int main()
{
    //freopen("int.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    memset(dp,-1,sizeof(dp));
    scanf("%d %d",&n,&m);
    for(int i = 1;i <= n;i++)
        for(int j = 1;j <= m;j++)
            scanf("%d",&a[i][j]);
    dp[1][1] = a[1][1];
    int ans = -1;
    for(int i = 1;i <= n;i++)
        for(int j = 1;j <= m;j++)
        {
            if(dp[i][j] < 0)
                continue;
            ans = max(dp[i][j],ans);
            for(int k = 0;k < 4;k++)
            {
                int x = i + X[k];
                int y = j + Y[k];
                if(!check(x,y))
                    continue;
                dp[x][y] = max(dp[i][j] + a[x][y],dp[x][y]);
            }

        }
    printf("%d\n",ans);
    return 0;
}

你可能感兴趣的:(UESTC,OJ,(CDOJ))