标签:inpu ring orm least val imu standard cti can
You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called health, and the health of the i-th monster is hi at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below.
Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows:
At least how many explosions do you need to cause in order to vanish all the monsters?
Constraints
Input
Input is given from Standard Input in the following format:
N A B h1 h2 : hN
Output
Print the minimum number of explosions that needs to be caused in order to vanish all the monsters.
Sample Input 1
4 5 3 8 7 4 2
Sample Output 1
2
You can vanish all the monsters in two explosion, as follows:
Sample Input 2
2 10 4 20 20
Sample Output 2
4
You need to cause two explosions centered at each monster, for a total of four.
Sample Input 3
5 2 1 900000000 900000000 1000000000 1000000000 1000000000
Sample Output 3
800000000
二分啊啊啊 这么大的数 不二分怎么写
1 #include <iostream> 2 using namespace std; 3 #include<string.h> 4 #include<set> 5 #include<stdio.h> 6 #include<math.h> 7 #include<queue> 8 #include<map> 9 #include<algorithm> 10 #include<cstdio> 11 #include<cmath> 12 #include<cstring> 13 #include <cstdio> 14 #include <cstdlib> 15 #include<stack> 16 #include<vector> 17 long long a[51000000]; 18 long long n,a1,b1; 19 long panduan(long long zhi) 20 { 21 long long t=b1*zhi; 22 long long add=0; 23 for(int i=1;i<=n;i++) 24 { 25 if(a[i]-t>0) 26 { 27 if((a[i]-t)%(a1-b1)==0) 28 add+=(a[i]-t)/(a1-b1); 29 else 30 add+=(a[i]-t)/(a1-b1)+1; 31 } 32 } 33 //cout<<zhi<<"_"<<add<<endl; 34 return add<=zhi; 35 } 36 int main() 37 { 38 cin>>n>>a1>>b1; 39 for(int i=1;i<=n;i++) 40 scanf("%d",&a[i]); 41 long long kaishi=0,jieshu=1e9; 42 long long mid; 43 //cout<<panduan(3)<<"_"<<endl; 44 int t; 45 while(kaishi<jieshu-1) 46 { 47 //cout<<kaishi<<"_"<<jieshu<<endl; 48 mid=(jieshu+kaishi)>>1; 49 if(panduan(mid)) 50 { 51 jieshu=mid; 52 t=mid; 53 } 54 else 55 kaishi=mid; 56 } 57 cout<<jieshu<<endl; 58 return 0; 59 }
标签:inpu ring orm least val imu standard cti can
原文地址:http://www.cnblogs.com/dulute/p/7966703.html