Comments

#include<bits/stdc++.h> using namespace std; #define pi acos(-1.0) pair< double, double> rot(pair< double, double> i, double theta) { return {i.first*cos(theta)+i.second*sin(theta),-i.first*sin(theta)+i.second*cos(theta)}; } int main() { int t; cin>>t; while(t--) { long long a,b,m,n,theta; cin>>a>>b>>m>>n>>theta; vector<pair< double, double>>pp; long long g=gcd(m,n); m/=g; n/=g; pp.emplace_back(0,0); pp.emplace_back(b,0); pp.emplace_back(b,a); pp.emplace_back(0,a); for(auto &i:pp) { i=rot(i,pi*theta/180.0); } double d1=1e10, d2=1e10; for(auto i:pp) { d1=min(d1,i.first); d2=min(d2,i.second); } double wd=0,hd=0; for(auto &i:pp) { i.first-=d1; i.second-=d2; wd=max(i.first,wd); hd=max(i.second,hd); } long long lo=0,hi=1e10,ans=0; while(lo<=hi) { long long mi=(lo+hi)/2; long long w=n*mi,h=m*mi; if(wd-w<=1e-6 and hd-h<=1e-6) { hi=mi-1; ans=mi; } else lo=mi+1; } cout<<m*ans<<" "<<n*ans<<endl; } return 0; }

In the code above if eps>1e-6 i got an WA . And how someone possibly know that he will got an WA for that ?

Answer is yes if password is not a subsequent of password database. Since 71 is not present as a subsequent ans of greedy is yes

0

+++

...

...

Consider a string, num the password database.

Our objective is to select digits in such a way that we surpass the length of the password database, len(num). When faced with multiple options for choosing digits, it is optimal to take the digit which's index is right most among all the available options.

This strategy increases the likelihood of selecting digits that eventually result in exceeding the length of num.

consider the case

88005553535123456

2

40

56

here for the first selection here we can take index 4 or 14 [0 based indexing], it is optimal to take 14 . Because the next index we will be selecting is will be right from 14 which has a higher possibility to surpass the length of password database in the next selection.

have you read the problem statement?

An arithmetic array is an array that contains at least two integers and the differences between consecutive integers are equal. and you have to find the length of the longest possible arithmetic subarray.

here 5 5 4 5

so, the differences are 0 1 -1