zoukankan      html  css  js  c++  java
  • 2014ACM/ICPC亚洲区北京站

    1001  A Curious Matt

    求一段时间内的速度单位时间变化量,其实就是直接求出单位时间内的,如果某段时间能达到最大那么这段时间内必定有一个或一小段单位时间内速度变化是最大的即局部能达到最大,比较水就是格式上有点坑,谜之wa了好几发

     1 #include <stdio.h>
     2 #include <stdlib.h>
     3 #include <string.h>
     4 #include <math.h>
     5 #include <algorithm>
     6 #include <iostream>
     7 typedef long long ll;
     8 using namespace std;
     9 
    10 
    11 struct Node
    12 {
    13     ll t,x;
    14  }p[100005];
    15  
    16  int cmp(Node a,Node b)
    17  {
    18      return a.t<b.t;
    19  }
    20  
    21  int main()
    22  {
    23      int cas,n,i;
    24      scanf("%d",&cas);
    25      for(i=1;i<=cas;i++)
    26      {
    27          scanf("%d",&n);
    28          for(int j=0;j<n;j++)
    29              scanf("%lld %lld",&p[j].t,&p[j].x);
    30          sort(p,p+n,cmp);
    31          
    32          double max=abs(p[1].x-p[0].x)/(p[1].t-p[0].t);
    33 
    34          for(int j=1;j<n;j++)
    35          {
    36              if((abs(p[j].x-p[j-1].x)/(p[j].t-p[j-1].t))>max)
    37                 max=1.0*abs(p[j].x-p[j-1].x)/(p[j].t-p[j-1].t); 
    38          }
    39         printf("Case #%d: %.2lf
    ",i,max);
    40     }
    41      return 0;
    42  }

     1011 K.Bro Sorting

    一道比较水的题目,求出逆序数字的对数就行

     1 #include<cstdio>  
     2 #include<iostream>  
     3 #include<algorithm>
     4 #include<math.h> 
     5 #include<string.h>  
     6 #include<vector> 
     7 #include<queue>
     8 #include<iterator>
     9 #include<vector>
    10 #include<set>
    11 #define dinf 0x3f3f3f3f
    12 typedef long long ll;
    13 using namespace std;
    14 #define SIZE 100000005
    15 
    16 
    17 ll a[1000005];
    18 
    19 
    20 
    21 int main()
    22 {
    23     int n,cas,ans;
    24     scanf("%d",&cas);
    25     for(int k=1;k<=cas;k++)
    26     {
    27         scanf("%d",&n);
    28         ans=0;
    29         for(int i=0;i<n;i++)
    30             scanf("%lld",&a[i]);
    31         int min=a[n-1];
    32         for(int i=n-2;i>=0;i--)
    33         {
    34             if(a[i]>min)
    35                 ans++;
    36             else 
    37                 min=a[i];
    38              
    39          } 
    40         printf("Case #%d: %lld
    ",k,ans);
    41     } 
    42    
    43     return 0;
    44 }
  • 相关阅读:
    258. Add Digits 数位相加到只剩一位数
    7. Reverse Integer 反转整数
    9. Palindrome Number 回文数的判断
    824. Goat Latin山羊拉丁文
    819. Most Common Word 统计高频词(暂未被禁止)
    Angular 2 模板语法
    HTML DOM Style opacity 属性
    Basic concepts (C language) – C 中文开发手册
    JavaScript手册 | JS Array 对象中的fill()方法
    HTML <form> 标签
  • 原文地址:https://www.cnblogs.com/pter/p/5973505.html
Copyright © 2011-2022 走看看