zoukankan      html  css  js  c++  java
  • FZU 2212 Super Mobile Charger 第六届福建省赛

    题目链接:http://acm.fzu.edu.cn/problem.php?pid=2212

    题目大意:

    现在有n个手机,一个电量为m%(百分之m)的万能充电宝
    然后输入n个手机的现有电量(百分之a[i]),现在问你这个万能充电宝能把几个手机充满(电量为百分之百)。
    //思路:
    将n个手机的电量进行一个排序,从最满的开始充,每充满一个手机,充电宝的电就要减去消耗的电量,如果充电还有电则代表此手机充电成功,如此一来,就可以计算充电宝能将几个手机充满了
    AC代码:
    #include <cstdio>
    #include <algorithm>
    #include <iostream>
    #include <cstring>
    #include <vector>
    using namespace std;
    int a[105];
    int main()
    {
     int t,n,m;
     scanf("%d",&t);
     while(t--)
     {
      int ans=0;
      scanf("%d %d",&n,&m);
      for(int i=0;i<n;i++)
      scanf("%d",&a[i]);
      sort(a,a+n);
      for(int i=n-1;i>=0;i--)
      {
       m-=100-a[i];
       if(m>=0) ans++;
       else break;
      }
      printf("%d
    ",ans);
     }
     return 0;
    }
  • 相关阅读:
    jq的遍历与杂项
    jq的事件
    jquery的效果
    jquery入门
    面向对象。对象的继承
    面向对象克隆对象
    面向对象this指向问题
    实例对象及原型链
    GCD多线程任务总结
    C语言链表的简单实用
  • 原文地址:https://www.cnblogs.com/www-cnxcy-com/p/5755690.html
Copyright © 2011-2022 走看看