• HDU4519


    一种比较挫的写法

     1 /*
     2 模拟
     3 */
     4 #include<stdio.h>
     5 #include<string.h>
     6 #include<stdlib.h>
     7 #include<algorithm>
     8 #include<iostream>
     9 #include<queue>
    10 #include<stack>
    11 #include<math.h>
    12 #include<map>
    13 using namespace std;
    14 const int maxn = 105;
    15 
    16 int cmp( int a,int b ){
    17     return a>b;
    18 }
    19 
    20 int main(){
    21     int ca;
    22     scanf("%d",&ca);
    23     while( ca-- ){
    24         int n,m,k;
    25         scanf("%d%d%d",&n,&k,&m);
    26         int a[ maxn ];
    27         for( int i=0;i<n;i++ )
    28             a[i] = k;
    29         int ans = 0;
    30         while( 1 ){
    31             sort( a,a+n,cmp );
    32             if( a[0]<=0 ) break;
    33             for( int i=0;a[i]>0&&i<min(n,m);i++ ) 
    34                 a[ i ]--;
    35             ans++;
    36         }
    37         printf("%d
    ",ans);
    38     }
    39     return 0;
    40 }
    View Code

    另外一种方法

     1 /*
     2 模拟
     3 */
     4 #include<stdio.h>
     5 #include<string.h>
     6 #include<stdlib.h>
     7 #include<algorithm>
     8 #include<iostream>
     9 #include<queue>
    10 #include<stack>
    11 #include<math.h>
    12 #include<map>
    13 using namespace std;
    14 const int maxn = 105;
    15 const double eps = 0.99999999;
    16 
    17 int main(){
    18     int ca;
    19     scanf("%d",&ca);
    20     while( ca-- ){
    21         int n,m,k;
    22         scanf("%d%d%d",&n,&k,&m);
    23         if( m>=n ){
    24             printf("%d
    ",k);
    25             continue;
    26         }
    27         if( (n*k)%m==0 ) printf("%d
    ",n*k/m);
    28         else printf("%d
    ",n*k/m+1);
    29     }
    30     return 0;
    31 }
    View Code
    keep moving...
  • 相关阅读:
    easyui-layout完整web界面布局
    combobox中动态载入tree数据
    easyui---layout 有无横的间隔 的区别 split:true
    单选按钮radio获取选中的值
    Datagrid清空数据
    Lancher3默认桌面显示
    菜单背景全透效果
    android通过耳机控制音乐播放器
    android 音乐暂停
    Android 系统默认音量和最大音量
  • 原文地址:https://www.cnblogs.com/xxx0624/p/3180133.html
Copyright © 2020-2023  润新知