zoukankan      html  css  js  c++  java
  • [CF套题] CF-1163

    CF-1163

    传送门

    # Penalty A B1 B2 C1 C2 D E F
    3 (483) 464 +0 0:06 +1 01:13 +3 01:12 + 01:57 + 01:56

    A

    第一个人离开时候不增加,第二个人离开时候隔一个走开

    当m=0时,答案为0

    n为偶数时,如果2m<=n那么答案为m,否则为n-m

    n为奇数时,如果2m<=n那么答案为m,否则为n-m,可以发现奇偶是一样的

    int n,m;
    int main() 
    {
        cin>>n>>m;
        if(m == 0){
            cout<<1<<endl;return 0;
        }
        else if(n == 1){
            cout<<1<<endl;return 0;
        }
        else if(2 * m <= n){
            cout<<m<<endl;
        }
        else cout<<n-m<<endl;
        return 0;
    }
    

    B

    做B题心态崩了,这到场上肯定被hack

    case并不多,但一定要细心想

    • 全是一种颜色
    • 所有的颜色出现次数为1
    • 有一个颜色出现次数为1,其他为某种同样大小的次数
    • 有一个颜色出现次数为x+1,其他颜色出现次数为x
    #include <stdio.h>
    #include <iostream>
    #include <cstdlib>
    #include <cmath>
    #include <cctype>
    #include <string>
    #include <cstring>
    #include <algorithm>
    #include <stack>
    #include <queue>
    #include <set>
    #include <map>
    #include <ctime>
    #include <vector>
    #include <fstream>
    #include <list>
    #include <iomanip>
    #include <numeric>
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    #define ms(s) memset(s, 0, sizeof(s))
    const int inf = 0x3f3f3f3f;
    const int N = 1e5+10;
    int n,u[N],c[N],num[N],cnt;
    int main() 
    {
        cin>>n;
        int res = 1;
        for(int i=1;i<=n;i++){
            scanf("%d",&u[i]);
            if(c[u[i]] == 0){
                c[u[i]] ++;
                num[1]++;
                cnt++;
            }
            else{
                num[c[u[i]]] --;
                c[u[i]]++;
                num[c[u[i]]] ++;
            }
            if(num[c[u[i]]] == i)res = i;//case1
            if(num[1] == i)res = i;//case2
            if(i > 1 && c[u[i]] == 1 && (i-1) % (cnt-1) == 0 && num[(i-1)/(cnt-1)] == cnt-1)//case3.1
                res = i;
            if(num[c[u[i]]] * c[u[i]] == i-1){//case3.2
                res = i;
            }
            if(num[c[u[i]]] == 1 && num[c[u[i]]-1] == cnt-1)res = i;
            if(num[c[u[i]]] == cnt - 1 && num[c[u[i]]+1] == 1)res = i;
        }
        cout<<res<<endl;
        return 0;
    }
    

    C

    存下每条直线,平行的直线不计算到答案中

    const int N = 1010;
    int n;
    int x[N],y[N];
    map<pair<int,int> ,set<int > > mp;
    int main() 
    {
        cin>>n;
        ll res = 0;
        ll tot = 0;//直线总数
        for(int i=1;i<=n;i++)scanf("%d%d",&x[i],&y[i]);
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(i == j)continue;
                int x1 = x[i], x2 = x[j];
                int y1 = y[i], y2 = y[j];
                int dx = x[i] - x[j];
                int dy = y[i] - y[j];
                int g = __gcd(dx,dy);
                dx /= g;dy /= g;
                if(dx < 0 || (dx == 0 && dy < 0)){
                    dx = -dx;
                    dy = -dy;
                }
                int c = dx * y1 - dy * x1;//求解直线dx*y = dy * x + c 
                if(!mp[{dx,dy}].count(c)){//如果直线没有记录过
                    tot++;
                    mp[{dx,dy}].insert(c);
                    res += tot - mp[{dx,dy}].size();//tot要减去与它平行的直线
                }
            }
        }
        cout<<res<<endl;
        return 0;
    }
    

    D

    留坑

    E

    留坑

  • 相关阅读:
    总结:Sharepoint2010 Client Object Model Managed Client
    学习:SharePoint验证控件
    学习:Javascript与后台交互(转)
    总结:sharepoint webservice开发常见错误
    Xtreme ToolkitPro 版本更新至 2007 Volume 1
    WebUI Studio.NET® 优秀用户界面控件套装
    Spread v7.0 表格控件中的领头羊
    WebUI Studio.NET® 2007 R1 用户界面套装新版本发布,全面支持AJAX技术
    Skelta SharePoint Accelerator
    磐岩科技控件中国网乔迁新址
  • 原文地址:https://www.cnblogs.com/1625--H/p/11361241.html
Copyright © 2011-2022 走看看