【更新中】2016年ACM/ICPC Asia Dalian Regional Contest补题

比赛链接:
https://vjudge.net/contest/364713#overview

C - Game of Taking Stones

https://vjudge.net/contest/364713#problem/C

题意:威佐夫博弈
思路:高精即可

此题不补,没意思
D - A Simple Math Problem

https://vjudge.net/contest/364713#problem/D

题意:给定a、b,求一对X,Y使得X+Y=a,LCM(X,Y)=b
思路:首先

gcd * lcm = a * b

设x’gcd(a,b) = a, y’gcd(a,b) =b,带入即让方程有解即可。


int main() {
    
    
    ios::sync_with_stdio(0);
    ll a, b;
    while(cin >> a >> b) {
    
    
        ll g = gcd(a, b);
        ll delta = a * a - 4 * b * g;
        if(delta < 0 || sqrt(delta) * sqrt(delta) != delta) {
    
    cout << "No Solution" << endl; continue;}

        ll x1 = a - sqrt(delta), x2 = a + sqrt(delta);
        if(x1 & 1 || x2 & 1) cout << "No Solution" << endl;
        else cout << x1 / 2 << " " << x2 / 2 << endl;
    }

    return 0;
}

E - Aninteresting game

https://vjudge.net/contest/364713#problem/E

H - To begin or not to begin

https://vjudge.net/contest/364713#problem/H

题意:一个盒子里面有一个红球,k - 1个黑球,两个人轮流拿。拿到红球即为胜,对两个选手的其中一个做决策,先拿胜的概率低还是高。

思路:演我。。找规律,奇数高偶数低。

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 100;
const int mod = 1e9 + 7;

int a[maxn];
const double pi = 4 * atan(1.0);
int main() {
    
    
    ios::sync_with_stdio(0);
    int k;
    while(cin >> k) {
    
    
        if(k & 1) cout << 0 << endl;
        else cout << 1 << endl;
    }

    return 0;
}

H - To begin or not to begin

https://vjudge.net/contest/364713#problem/I

题意:给定一个凸包和原点连线的若干个相邻夹角度数和连线的长度(都相等),求它的面积。

思路:

n * a * b * sin(theta) / 2
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 100;
const int mod = 1e9 + 7;
int gcd(int a, int b) {
    
    
    if(!b) return a;
    else return gcd(b, a % b);
}
int a[maxn];
const double pi = 4 * atan(1.0);
int main() {
    
    
   // ios::sync_with_stdio(0);
    int n, m;
    while(scanf("%d%d" ,&n, &m) != EOF) {
    
    
        double sum = 0;
        for(int i = 1; i <= n; i++) {
    
    
            scanf("%d", &a[i]);
            sum += m * m * sin(a[i] / 180.0 * pi) * 0.5;
        }

        printf("%.3f\n", sum);
    }

    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_43269437/article/details/105211033
今日推荐