#include<iostream>#include<string>#include<iomanip>#include<vector>#include<set>#include<cmath>#include<stack>#include<queue>#include<algorithm>#include<cmath>#include<map>#include<cstring>#include<list>#include<numeric>#include<bitset>#define int long longusingnamespace std;typedeflonglong ll;constint maxn =2e5+5;int row_z[maxn];int col_z[maxn];int a[maxn];int fac[16];char martix[405][405];int dp[405][405];voidset_fac(){
fac[0]=0;fac[1]=1;for(int i =2; i <=16;++i){
fac[i]= fac[i-1]*i;}// for (int i = 0; i < 16; ++i) {
// cout<<fac[i]<<" ";// }}voidsolve(){
set_fac();int n;cin>>n;bitset<40>init(n);int ans =(int) init.count();for(int i =0; i <=(1<<15);++i){
int nn = n;bitset<16>facn(i);for(int j =0; j <16;++j){
if(facn[j]==1) nn-=fac[j];}if(nn>=0){
bitset<40>binn(nn);ans =min(ans,(int)(binn.count()+facn.count()));}}cout<<ans<<'\n';}signedmain(){
std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);int t;cin >> t;for(int i =0; i < t;++i){
solve();}}
#include<iostream>#include<string>#include<iomanip>#include<vector>#include<set>#include<cmath>#include<stack>#include<queue>#include<algorithm>#include<cmath>#include<map>#include<cstring>#include<list>#include<numeric>#include<bitset>#define int long longusingnamespace std;typedeflonglong ll;constint maxn =2e5+5;int row_z[maxn];int col_z[maxn];int a[maxn];char martix[405][405];int dp[405][405];voidsolve(){
int n;cin>>n;for(int i =0; i < n;++i){
cin>>a[i];}sort(a,a+n);int suma = a[n-1];int sumb = a[0]+a[1];int left =2,right = n-2;while(left<right && suma<=sumb){
suma+=a[right];sumb+=a[left];left++;right--;}if(suma>sumb) cout<<"yes"<<'\n';else cout<<"no"<<'\n';signedmain(){
std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);int t;cin >> t;for(int i =0; i < t;++i){
solve();}}
A. Square Counting
思路
n个小于n的数不可能凑出n2,所以有s/(n2)个n^2
经验教训
无
AC代码
#include<iostream>#include<string>#include<iomanip>#include<vector>#include<set>#include<cmath>#include<stack>#include<queue>#include<algorithm>#include<cmath>#include<map>#include<cstring>#include<list>#include<numeric>#include<bitset>#define int long longusingnamespace std;typedeflonglong ll;constint maxn =2e5+5;int row_z[maxn];int col_z[maxn];char martix[405][405];int dp[405][405];voidsolve(){
int n,s;cin>>n>>s;int xx = n*n;cout<<s/xx<<'\n';}signedmain(){
std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);int t;cin >> t;for(int i =0; i < t;++i){
solve();}}