• 2017 7.25多校训练第一场补题


     一题签到 -1 和不减的位数相同,故可简化

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 typedef long long ll;
     4 int main(){
     5     int n;
     6     int k=1;
     7     while(cin>>n){
     8         ll ans=n*log(2)/log(10);
     9         printf("Case #%d: %lld
    ",k++,ans);
    10     }
    11 }
    View Code

    6040 解题关键:nth_element的使用,注意将区间可以缩小,以及int和unsigned之间直接转化会出错。

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 typedef long long ll;
     4 unsigned rating[10000009];
     5 unsigned ans[188];
     6 struct node{
     7     int id;
     8     int ra;
     9 }arr[199];
    10 bool cmp(node &a,node &b){
    11     return a.ra>b.ra;
    12 }
    13 unsigned x,y,z;
    14 unsigned rng61(){
    15       unsigned t;
    16       x ^= x << 16;
    17       x ^= x >> 5;
    18       x ^= x << 1;
    19       t = x;
    20       x = y;
    21       y = z;
    22       z = t ^ x ^ y;
    23       return z;
    24 }
    25 int main(){
    26     int n,m;
    27     unsigned a,b,c;
    28     int k=1;
    29     while(scanf("%d%d%u%u%u",&n,&m,&a,&b,&c)!=EOF){
    30         x=a,y=b,z=c;
    31         for(int i=0;i<m;i++)     {cin>>arr[i].ra;arr[i].id=i;} 
    32         for(int i=0;i<n;i++)    rating[i]=rng61();
    33         sort(arr,arr+m,cmp);
    34         int temp=n;
    35         for(int i=0;i<m;i++){
    36             nth_element(rating,rating+arr[i].ra,rating+temp);
    37             temp=arr[i].ra;
    38             ans[arr[i].id]=rating[temp];
    39         }
    40         printf("Case #%d: ",k++);
    41         for(int i=0;i<m;i++){
    42             printf("%u%c",ans[i],i==m-1?'
    ':' ');
    43         }
    44     }
    45     return 0;
    46 }
    View Code

    弱渣待补。

    另一签到:1010 找规律

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 typedef long long ll;
     4 int main(){
     5     ll n,k,t;
     6     int tt=1;
     7     while(cin>>n>>k){
     8         if(n==2){
     9             ll ans;
    10              t=k%n;
    11             if(t==0) ans=2;
    12             else ans=1;
    13             printf("Case #%d: %lld
    ",tt++,ans);
    14             continue;
    15         }
    16         
    17         ll t1=(k-n)%(n-1),t2=(k-n)/(n-1);
    18         ll ans;
    19         if(k<=n) ans=k;
    20         else{
    21             if(t2%2==0&&t1==0){
    22                 ans=n;
    23             }
    24             else if(t2%2==1&&t1==0){
    25                 ans=n-1;
    26             }
    27             else{
    28                 ans=t1;
    29             }
    30         }
    31         printf("Case #%d: %lld
    ",tt++,ans);
    32     }
    33 }
    View Code
  • 相关阅读:
    高级定制_百度百科
    大叔也学Xamarin系列
    WebApi系列~dynamic让你的省了很多临时类
    大叔也说Xamarin~Android篇~支付宝SDK的集成
    知方可补不足~sqlserver中使用ROW_NUMBER进行的快速分页
    EF架构~有时使用SQL更方便
    【deep learning学习笔记】注释yusugomori的LR代码 --- LogisticRegression.h
    线程同步
    泛型接口的实现方式之二
    jsp获得本地及serverIP的方法
  • 原文地址:https://www.cnblogs.com/elpsycongroo/p/7242745.html
Copyright © 2020-2023  润新知