2018/ICPC南京 补题 (人生阴影)

补题链接:https://codeforces.com/gym/101981

 

具体的细节 真的不想描述了 , 说多少次,难过多少次 ,遗憾。

过了很久才想起来写这个比赛的博客,随便写一下吧

看题吧

A题 给你一些连续的数字,每次取连续的1到k个数字,问先手后手谁赢(某队友一上来写了个那什博弈,问了几句连续的影不影响,结果秒wa),其实从中间取,然后再对称着取就OK了

#include <bits/stdc++.h>
#include <time.h>
#define first fi
#define second se


using namespace std;

typedef long long ll;
typedef double db;
const double eps = 1e-9;
typedef pair<int,int>  P;
const int maxn = 2e6 + 5000;
bool vis[maxn];
queue<pair<string,int> >q;
const ll mod = 1e9 + 7;
inline int sign(db a) { return a < -eps ? -1 : a > eps;}
inline int cmp(db a,db b){ return sign(a - b);}
ll mul(ll a,ll b,ll c) { ll res = 1; while(b) {  if(b & 1) res *= a,res %= c;  a *= a,a %= c,b >>= 1;  }  return res;}
ll phi(ll x) {  ll res = x;  for(ll i = 2; i * i <= x; i++) { if(x % i == 0) res = x / i * (i - 1);   while(x % i == 0) x /= i;   }  if(x > 1) res = res / x  * (x - 1);    return res;}
ll c,n,k;
int main() {
    ios::sync_with_stdio(false);
    while(cin >> n >> k){ 
            if(n == 0)
            {  
            cout << "Austin" << endl;
            continue;
            }
        if(n % 2 == 0 && k == 1){
            cout << "Austin" << endl;
        }else
            cout << "Adrien" << endl;
    }
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}

D:最小覆盖球 近乎模板题,当时没有板子。。。也不会模拟退火,也不会三分套三分,太菜了就挂掉了。。。 

int fa[maxn];
int Find(int x) {   if(x != fa[x]) return fa[x] = Find(fa[x]);  return fa[x];}
ll c,n,k;
struct Point{
    double x,y,z;
}g[maxn];
double dis(Point a,Point b){
    return  sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z));;
}double ans = 1e20;
void sa(){
    Point s;
    double d = 100000;
    s.x = 0,s.y = 0,s.z = 0;
    while(d > eps){
        int t = 1;
        for(int i = 2;i <= n;i++){
            if(dis(s,g[i]) > dis(s,g[t])) t = i;
        }
        double r = dis(s,g[t]);
        ans = min(ans,r);
        s.x += (g[t].x - s.x) / r * d;
        s.z += (g[t].z - s.z) / r * d;
        s.y += (g[t].y - s.y) / r * d;
        d *= 0.98;
    }
}
int main() {
//    ios::sync_with_stdio(false);
    while(cin >> n){
        ans = 1e20;
            if(n == 0) break;
        for(int i = 1;i <= n;i++) cin >> g[i].x >> g[i].y >> g[i].z;
        sa();
        sa();
        sa();
        sa();
        sa();
    printf("%.5f\n",ans);
    }
    cerr << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}

G 问最多可以有多少等边三角形,推出来下面一个是70,蒙了一下公式(n) * (n + 3) * (n + 2) * (n + 1) / 24,取下逆元

#include <bits/stdc++.h>
#include <time.h>
#define first fi
#define second se


using namespace std;

typedef long long ll;
typedef double db;
const double eps = 1e-9;
typedef pair<int,int>  P;
const int maxn = 2e6 + 5000;
bool vis[maxn];
queue<pair<string,int> >q;
const ll mod = 1e9 + 7;
inline int sign(db a) { return a < -eps ? -1 : a > eps;}
inline int cmp(db a,db b){ return sign(a - b);}
ll mul(ll a,ll b,ll c) { ll res = 1; while(b) {  if(b & 1) res *= a,res %= c;  a *= a,a %= c,b >>= 1;  }  return res;}
ll phi(ll x) {  ll res = x;  for(ll i = 2; i * i <= x; i++) { if(x % i == 0) res = x / i * (i - 1);   while(x % i == 0) x /= i;   }  if(x > 1) res = res / x  * (x - 1);    return res;}
ll c,n,k;
int main() {
//    cout <<mul(24ll,mod - 2,mod);
    int t;
    scanf("%d",&t);
    while(t--){
        scanf("%lld",&n);
        ll ans = (n + 1) * n % mod * (n + 2) % mod * (n + 3) % mod * mul(24ll,mod - 2,mod) % mod;
        printf("%lld\n",ans);
     }
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}

I 网络流模板题??个人不会网络流,因为当时翻译错题,最后20分钟才知道那是k回合,很明显二分图的模板题啊,最后写了二分图,交上去两发,一次RE, 一次 WA, 最后结束了 ,精神恍惚,不想动 , 后来在cf上开了重现,一A过的 ,搞不明白当时哪里写错了。。。队友也不会这个 ,也没看出来。

就是先跑一次匹配,然后第二次和k取个min即可

#include <bits/stdc++.h>

using namespace std;

int v[505][505];
int n,m;
;
int used[5000];
int nxt[5000];
bool Find(int x) {
    for(int i = 1; i <= m; i++) {
        if(used[i] == 0 && v[x][i]) {
            used[i] = 1;
            if(nxt[i] == 0 || Find(nxt[i])) {
                nxt[i] = x;
                return true;
            }
        }
    }
    return false;
}
int match() {
    int sum  = 0;
    for(int i = 1; i <= n; i++) {
        memset(used,0,sizeof(used));
        if(Find(i)) sum++;
    }
    return sum;
}
int main() {
    int k;
    while(cin >> n >> m >> k) {
            int x,y;
        memset(v,0,sizeof(v));
        memset(nxt,-1,sizeof(0));
        for(int i = 1; i <= n; i++) {
            cin >> x;
            for(int j = 0; j < x; j++) {
                cin >> y;
                v[i][y] = 1;
//                v[x].push_back(y);
            }
        }
        long long ans = match();
        ans += min(match(),k);
         cout << ans << endl;

    }
    return 0;
}

 

J : 计数的好题,Let mul(l, r) = ∏r i=l ai and fac(l, r) be the number of distinct prime factors of mul(l, r). Please calculate ∑n i=1 ∑n j=i fac(i, j) ,计算不同素因子的个数,然后加起来,对每个数分解,然后技巧计数一下即可

#include <bits/stdc++.h>
#include <time.h>
#define first fi
#define second se


using namespace std;

typedef long long ll;
typedef double db;
const double eps = 1e-9;
typedef pair<int,int>  P;
const int maxn = 1e6 + 10;
queue<pair<string,int> >q;
const ll mod = 1e9 + 7;
inline int sign(db a) {
    return a < -eps ? -1 : a > eps;
}
inline int cmp(db a,db b) {
    return sign(a - b);
}
ll mul(ll a,ll b,ll c) {
    ll res = 1;
    while(b) {
        if(b & 1) res *= a,res %= c;
        a *= a,a %= c,b >>= 1;
    }
    return res;
}
ll phi(ll x) {
    ll res = x;
    for(ll i = 2; i * i <= x; i++) {
        if(x % i == 0) res = x / i * (i - 1);
        while(x % i == 0) x /= i;
    }
    if(x > 1) res = res / x  * (x - 1);
    return res;
}
ll prime[maxn],vis[maxn],cnt = 0;
void Init() {
    memset(vis,0,sizeof(vis));
    vis[1] = vis[0] = 1;
    for(int i = 2; i < maxn; i++) {
        if(!vis[i]) {
            prime[cnt++] = i;
            for(int j = i + i; j < maxn; j += i) vis[j] = 1;
        }
    }
}
ll c,n,k;
ll a[maxn];
vector<vector<ll> >v;
int main() {
//    ios::sync_with_stdio(false);
    Init();
    while(~scanf("%lld",&n)) {
        v.resize(maxn);
        for(int i = 1; i <= n; i++)  scanf("%lld",&a[i]);
        for(int i = 1;i < maxn;i++) v[i].push_back(0);
        ll ans = 0;
        for(int i = 1;i <= n;i++) {
            ll x = a[i];
            for(int j = 0; prime[j] * prime[j] <= x; j++) {
                if(x % prime[j] == 0) {
                    while(x % prime[j] == 0) x /= prime[j];
                    v[prime[j]].push_back(i);
                }
            }
            if(x > 1) v[x].push_back(i);
        }
//        cout << prime[cnt - 1] << endl;
        for(int i = 0;i < maxn;i++){ 
                
            for(int j = 1;j < v[i].size();j++){
//                    cout << v[i][j] << " ";
                    ans += (ll)(v[i][j] - v[i][j - 1]) * (ll)(n - v[i][j] + 1ll);
            }
        }
        cout << ans << endl;
    }
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值