Good Bye 2018

Good Bye 2018

A - New Year and the Christmas Ornament

暴力 solved

#include <stdio.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map> 
#include <stack>
#include <sstream>
#include <set>
// #pragma GCC optimize(2)

//#define int long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define rush() int T;scanf("%d",&T);for(int Ti=1;Ti<=T;++Ti)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mm(i,v) memset(i,v,sizeof i);
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int > PII;
priority_queue< PII, vector<PII>, greater<PII> > que;
stringstream ssin; //  ssin << string   while ( ssin >> int)
const ll LINF = 0x7fffffffffffffffll;

const int N = 4e5 + 5, M = 4e5 + 5, mod = 1e9 + 7, INF = 0x3f3f3f3f;
int y, b, r;

inline ll read() {
    char c=getchar();ll x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1; c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0'; c=getchar();}
    return x*f;
}


int main()
{
    y = read(); b = read(); r = read();
    int ans = 6;
    for (int i = 1; i <= y; ++i) {
        for (int j = 1; j <= b; ++j) {
            for (int k = 1; k <= r; ++k) {
                if (i + 1 == j && j + 1 == k) {
                    ans = max(ans, i + j + k);
                }
            }
        }
    }
    cout << ans << '\n';
}
View Code

 

B - New Year and the Treasure Geolocation

暴力 solved

#include <stdio.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map> 
#include <stack>
#include <sstream>
#include <set>
// #pragma GCC optimize(2)

//#define int long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define rush() int T;scanf("%d",&T);for(int Ti=1;Ti<=T;++Ti)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mm(i,v) memset(i,v,sizeof i);
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)

using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int > PII;
priority_queue< PII, vector<PII>, greater<PII> > que;
stringstream ssin; //  ssin << string   while ( ssin >> int)
const ll LINF = 0x7fffffffffffffffll;

const int N = 4e5 + 5, M = 4e5 + 5, mod = 1e9 + 7, INF = 0x3f3f3f3f;
int n;
PII a[N], b[N];
map<PII, int>ma;

inline ll read() {
    char c=getchar();ll x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1; c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0'; c=getchar();}
    return x*f;
}


int main()
{
    n = read();
    for (int i = 1; i <= n; ++i) {
        a[i].first = read();
        a[i].second = read();
    }
    for (int i = 1; i <= n; ++i) {
        b[i].first = read();
        b[i].second = read();
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
//            printf("%d %d %d %d\n", a[i].first, a[i].second, b[i].first, b[i].second);
//            printf("%d---->%d\n", a[i].first + b[i].first, a[i].second + b[i].second);
            ma[{a[i].first + b[j].first, a[i].second + b[j].second}]++;
        }
    }
    for (auto x:ma) {
//        cout << x.first.first << "---" << x.first.second << " "  << x.second <<'\n';
        if (x.second == n) {
            cout << x.first.first << " " << x.first.second << '\n';
            return 0;
        }
    }
//    map<PII, int> ::iterator it;
//    for (it = ma.begin(); it != ma.end(); ++it) {
//        int m = *it.second;
//        if (m == n) {
//            cout << it.first << " " << it.second << '\n';
//            return 0;
//        }
//    }
}
View Code

 

C - New Year and the Sphere Transmission

找规律 solved

可以发现每个点可以走的方案就是其因数,只需把每个数的因数提取出来跑就行了

#include <stdio.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map> 
#include <stack>
#include <sstream>
#include <set>
// #pragma GCC optimize(2)

//#define int long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define rush() int T;scanf("%d",&T);for(int Ti=1;Ti<=T;++Ti)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mm(i,v) memset(i,v,sizeof i);
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)

using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int > PII;
priority_queue< PII, vector<PII>, greater<PII> > que;
stringstream ssin; //  ssin << string   while ( ssin >> int)
const ll LINF = 0x7fffffffffffffffll;

const int N = 4e5 + 5, M = 4e5 + 5, mod = 1e9 + 7, INF = 0x3f3f3f3f;
ll n;
vector<ll>ans, vec;

inline ll read() {
    char c=getchar();ll x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1; c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0'; c=getchar();}
    return x*f;
}


int main()
{
    n = read();
    if (!n) {
        cout << "1 " << (1 + n) * n / 2 << '\n';
    } else {
        for (int i = 2; i * i <= n; ++i) {
            if (n % i == 0) {
                vec.push_back(i);
                vec.push_back(n / i);
            }
        }
        for (auto x:vec) {
            ans.push_back((n - x + 2) * n / x / 2);
        }
        sort(ans.begin(), ans.end());
        ans.erase(unique(ans.begin(), ans.end()), ans.end());
        cout << "1 ";
        for (auto x:ans) {
            cout << x << " ";
        }
        cout << (1 + n) * n / 2 << '\n';
    }
}
View Code

 

D - New Year and the Permutation Concatenation

用next_permutation 暴力打了个表,nb队友直接凑出了个表达式就过了

f(n) = f(n - 1) * n + n! - n

#include <stdio.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map> 
#include <stack>
#include <sstream>
#include <set>
// #pragma GCC optimize(2)

//#define int long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define rush() int T;scanf("%d",&T);for(int Ti=1;Ti<=T;++Ti)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mm(i,v) memset(i,v,sizeof i);
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int > PII;
priority_queue< PII, vector<PII>, greater<PII> > que;
stringstream ssin; //  ssin << string   while ( ssin >> int)
const ll LINF = 0x7fffffffffffffffll;

const int N = 1e6 + 5, M = 4e5 + 5, mod =  998244353, INF = 0x3f3f3f3f;
ll f[N], jc[N];

inline ll read() {
    char c=getchar();ll x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1; c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0'; c=getchar();}
    return x*f;
}


int main()
{
    jc[0] = 1; jc[1] = 1;
    for (int i = 2; i < N; ++i) {
        jc[i] = jc[i - 1] * i % mod;
    }
    f[1] = 1;
    int n;
    n = read();
    for (int i = 2; i < N; ++i) {
        f[i] = f[i - 1] * i % mod + jc[i];
        f[i] %= mod;
        f[i] = f[i] - i + mod;
        f[i] %= mod;
    }
    cout << f[n] << '\n';
}
View Code

 

posted @ 2020-11-10 22:01  violet72  阅读(33)  评论(0编辑  收藏  举报