Solution to a problem yzoj P2345 war

Pure number theory

30: pure violence, t seconds after the direct simulation judgment, is smaller than 0 is determined hp

60 minutes: atk> = h, that is, a one shot, then the forces will min (n, t) is stopped after the second attack, the damage that the total A [n-+ (. 1-n-)
+ (n--2) + ... ..... (n-min (n, t) +1)

Arithmetic sequence summing d = a (2n-min (n, t) +1) * (min (n, t)) / 2;

If d> = hp Yes, or No;

100 points

Before considering the sum of t seconds military damage, hp and then compare the size of
the first count at several killed by a soldier, the set m
then m seconds before damage to NMA
m. 1 to 2m + seconds, damage of m (n-1) a
so
If not supported, then go to m (1) a
we consider support to separate its count
to the preceding time period, for each period experienced m s, k represents a set period of time has undergone several m seconds, then

k = min (n, t / m)

Let k th period damage to d = ma (n) + ma (n-1) ...... ma (n-k + 1)
number of arithmetic sequence summing d = (ma (2n-k + 1 ) k) / 2

If (t / m) <n && t mod m! = 0 then the there is a period of time, seconds t mod m experienced
damage to (t mod m) (a) (nk) was added in

Finally, whether d> = hp output if Yes, No or output

Code

#include<bits/stdc++.h>
using namespace std;
int T,flag;
long long hp,atk,n,h,a,t,atck,tmp,k;
int main(){
    scanf("%d",&T);
    while(T){
        scanf("%lld %lld %lld %lld %lld %lld",&hp,&atk,&n,&h,&a,&t);
        tmp=h/atk;
        if(h%atk!=0)tmp+=1;
        k=min(n,t/tmp);
        atck=tmp*a*(2*n-k+1)*k/2;
        if(t/tmp<n&&t%tmp!=0){
            atck+=t%tmp*a*(n-k);
        }
        if(atck>=hp){
            printf("Yes\n");
        }
        else printf("No\n");
        T--;
    }
    return 0;
}

Guess you like

Origin www.cnblogs.com/donkey2603089141/p/11416492.html