zoukankan      html  css  js  c++  java
  • CF#645div2

    A. Park Lighting:http://codeforces.com/contest/1358/problem/A

    Example

    input

    5

    1 1

    1 3

    2 2

    3 3

    5 3

    output

    1

    2

    2

    5

    8

    看完题解觉得自己是fw系列

    很简单的一道题

    如果两个边有一个边是偶数,就按照偶数那一侧来依次排过去,顺着一个方向就行

    也就是n*m/2

    如果都是奇数,那就n或者m进行-1按照上述方法,然后剩下部分分为n (m)-1 * 1 和 1*1两个部分了

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 
     4 int main(){
     5     int t;
     6     cin>>t;
     7     while(t--){
     8         int n,m;
     9         cin>>n>>m;
    10         if(n%2==0||m%2==0)cout<<n*m/2<<endl;
    11         else{
    12             int a=n*(m-1)/2;
    13             int b=(n-1)*1/2 +1;
    14             cout<<a+b<<endl;
    15         }
    16     }    
    17 }
    View Code

    B:Maria Breaks the Self-isolation

    http://codeforces.com/contest/1358/problem/B

    题解:好像,这个题也是个贪心

    直接一次就拉最多的人过去。

    #include<bits/stdc++.h>
    using namespace std;
    const int maxn=2e5+10;
    int test,n,a[maxn];
    int main(){
        cin>>test;
        while(test--){
            cin>>n;
            int vis[maxn]={0};
            for(int i=1;i<=n;i++)
                cin>>a[i],vis[a[i]]++;
            sort(a+1,a+1+n);
            int res=1, lef=0;
            for(int i=1;i<=n;i++){
                if(res+vis[a[i]]+lef-1>=a[i]){
                    res+=vis[a[i]]+lef;
                    lef=0;
                }
                else    lef+=vis[a[i]];
                i+=vis[a[i]]-1;
            }
            cout << res << endl;
        }
        return 0;
    }
    View Code

    C:Celex Update

    http://codeforces.com/contest/1358/problem/C

    题解:感觉让我想起了noip2017day2的t1,也是这样一个三角形

    找规律吧

    (感觉这次cf找规律的题居多诶)

    #include<bits/stdc++.h>
    #define ll long long
    #define maxn 200005
    using namespace std;
    int t,n,a[maxn];    
    int main(){
        cin>>t;
        while(t--){
            ll x1,x2,y1,y2;
            cin>>x1>>y1>>x2>>y2;
            ll res=(x2-x1)*(y2-y1)+1;
            cout<<res<<endl;
        }
    }
    View Code
  • 相关阅读:
    1155 Heap Paths (30 分)
    1147 Heaps (30 分)
    1098 Insertion or Heap Sort (25 分)
    12.SpringMVC 获得 请求头信息
    11.SpringMVC 获得Servlet相关API
    10.SpringMVC 自定义类型转换器
    18. VUE 数组的响应式
    017 vue 关于 v-for 指令内部算法
    17. VUE v-show 和 v-if 的区别
    16. VUE 的 小案列
  • 原文地址:https://www.cnblogs.com/Danzel-Aria233/p/13020366.html
Copyright © 2011-2022 走看看