Today is stupid day, Gufen 230, take-110. Which T2,4 not here just say that Italy and brief thoughts.
T1: Template title
This problem is relatively simple, that is, when read by a row of buckets, all the factors of the digital read one, then, again descending sweep, to look at whether the number i is a multiple of k, then the output It can be.
See Code:
#include<cstring> #include<cmath> #include<iostream> #include<algorithm> #include<cstdio> using namespace std; int n,v,k=1,maxx=-0x3f3f3f,a[100001],t[100001],b[100001]; void g(int x) { for(int i=1;i*i<=x;i++) { if(x%i==0) { t[i]++; t[x/i]++; if(i*i==x) t[i]--; } } } int main() { scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",&v); g(v); if(v>maxx) maxx=v; } for(int i=maxx;i>=1;i--) { while(t[i]>=k) { b[k]=i; k++; } } for(int i=1;i<=n;i++) printf("%d\n",b[i]); return 0; }
Good question indeed! ! !
T2: stretching
Because it is the n- 2 , but I will only simulate violence, so too.
T3: clues
Idea: when encounter left parenthesis, with a large root pile up savings. Then when the encounter left parenthesis, pressed into a small heap with, if left stack is empty, then pop the right piles top. Otherwise, left piles of top pop-up. Finally, if the pile is still not left empty, then left empty heap. This is clearly greedy correctness: When the left and right parenthesis encounter with a left parenthesis, priority take a big price to match. And if there is no left parenthesis, right parenthesis is not the minimum cost to use. Finally, how if left bracket, then all the pop-up.
See Code:
#include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> #include<queue> #define ll long long using namespace std; priority_queue<int,vector<int>,less<int> >q1; priority_queue<int,vector<int>,greater<int> >q2; ll n,k,k1=1,red,ans; char a[100001]; int main() { freopen("assassin.in","r",stdin); freopen("assassin.out","w",stdout); scanf("%lld",&n); for(ll i=1;i<=n;i++) scanf(" %c",&a[i]); for(ll i=1;i<=n;i++) { scanf("%lld",&red); if(a[i]=='(') { q1.push(red); } else { q2.push(red); if(!q1.empty()) { q1.pop(); k++; } else { ans+=q2.top(); q2.pop(); } } } while(!q1.empty()) { ans+=q1.top(); q1.pop(); } printf("%lld",ans); return 0; }
好题哉!!!
T4:自由
据大佬们说,此题是动归的斜率优化,当然数据有点小$n^{2}$也可以过。
但是……最基础的$n^{3}$我都不会。所以如清风般略过。
好题哉!!!