赞
踩
标签:思维
#include<bits/stdc++.h> #define ll long long #define LL unsigned long long #define up_b upper_bound #define low_b lower_bound #define all(a) begin(a),end(a) #define mem(a,n) memset(a,n,sizeof(a)) #define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; priority_queue <int,vector<int>,less<int> > QM; const int INF= 0x3f3f3f3f; const int maxn= 2e5+5; int a[110]; void solve() { int n;cin>>n; a[0]=-INF; int sum=0,ans=0; for(int i=1;i<=n;i++) { cin>>a[i]; if(a[i]==a[i-1]) sum++; else ans=max(ans,sum),sum=1; } ans = max(ans,sum); cout<<ans<<endl; } int main() { IOS; int t;cin>>t; while(t--){ solve(); } return 0; }
标签:数论
n = (d×10+k) + d×m → n = (d×10+d×m-d×m%10)+(d×m%10 + k)
此处的k∈[1,9],且m可取任意正整数,显然这个等式恒成立
证明:因为余数n%d ∈ [1,d-1],此时这个余数就对应式子中的((d×m)%10+k),而n的十位及以上的都可由(d×10+d×m-d×m%10)来消去。
#include<bits/stdc++.h> #define ll long long #define LL unsigned long long #define up_b upper_bound #define low_b lower_bound #define all(a) begin(a),end(a) #define mem(a,n) memset(a,n,sizeof(a)) #define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; priority_queue <int,vector<int>,less<int> > QM; const int INF= 0x3f3f3f3f; const int maxn= 2e5+5; int n,d,a[maxn]; bool check(int x) { if(x>=10*d) return 1; if(x%10==0) x-=d; while(x%10!=0 && x>=d) x-=d; if(x%10==0) return 1; return 0; } void solve() { cin>>n>>d; for(int i=1;i<=n;i++) { cin>>a[i]; if(check(a[i])) cout<<"YES"<<endl; else cout<<"NO"<<endl; } } int main() { IOS; int t;cin>>t; while(t--){ solve(); } return 0; }
标签:排序 数学
d1=d2 = 2×(a1+a2+a3+a4+a5+a6)
d3=d4 = 2×(a2+a2+a3+a4+a5+a6)
d5=d6 = 2×(a3+a3+a3+a4+a5+a6)
d7=d8 = 2×(a4+a4+a4+a4+a5+a6)
d9=d10 = 2×(a5+a5+a5+a5+a5+a6)
d11=d12 = 2×(a6+a6+a6+a6+a6+a6)
结果已经出来了,根据di的特征可知,特判di必定是两个两个相等的偶数。倒序依次推出a6—a1即可,期间特判ai必须为整数且大于0。
#include<bits/stdc++.h> #define ll long long #define LL unsigned long long #define up_b upper_bound #define low_b lower_bound #define all(a) begin(a),end(a) #define mem(a,n) memset(a,n,sizeof(a)) #define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; priority_queue <int,vector<int>,less<int> > QM; const int INF= 0x3f3f3f3f; const int maxn= 2e5+5; ll d[maxn],a[maxn],Q[maxn]; void solve() { int n;cin>>n; for(int i=1;i<=2*n;i++) cin>>d[i]; sort(d+1,d+1+2*n); ll sum=0; for(ll i=n;i>=1;i--) { if(d[i*2]!=d[i*2-1] || d[i*2]%2==1) { cout<<"NO"<<endl; return ; } Q[i] = d[i*2]/2; if((Q[i]-sum)%i!=0 || Q[i]<=sum) { cout<<"NO"<<endl; return ; } a[i] = (Q[i]-sum)/i; if(a[i]>=a[i+1] && i!=n) { cout<<"NO"<<endl; return ; } sum += a[i]; } cout<<"YES"<<endl; } int main() { IOS; int t;cin>>t; while(t--){ solve(); } return 0; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。