zoukankan      html  css  js  c++  java
  • AtCoder Beginner Contest 169

    A

    #include<bits/stdc++.h>
    using namespace std;
    
    int main(){
    	int a, b; cin>>a>>b; cout<<a*b<<endl;
    	return 0;
    }
    

    B

    为了避免溢出就用 py 写了

    import sys
    
    n=int(input())
    cur=1
    ok=True
    
    a = list(map(int, input().split(' ')))
    
    for i in range(n):
    	if a[i]==0:
    		print(0)
    		sys.exit()
    	
    
    for i in range(n):
    	if cur*a[i]>int(1e18):
    		print('-1')
    		ok=False
    		break;
    	cur*=a[i]
    
    
    if ok:
    	print(cur)
    

    C

    #include<bits/stdc++.h>
    using namespace std;
    
    int main(){
    	long long a; string t; cin>>a>>t;
    	int b=0;
    	for(int i=0; i<t.size(); i++) if(t[i]!='.') b=b*10+t[i]-'0';
    	cout<<a*b/100;
    	
    	return 0;
    }
    

    D

    不需要什么思维的题emm
    直接质因数分解,然后暴力地划分即可。

    #include<bits/stdc++.h>
    using namespace std;
    
    #define int long long
    
    #define x first
    #define y second
    
    map<int, int> prime_factor(int x){
        map<int, int> res;
        for(int i=2; i<=x/i; i++){
            while(x%i==0){
                res[i]++;
                x/=i;
            }
        }
        if(x!=1) res[x]=1;
        return res;
    }
    
    signed main(){
    	int x; cin>>x;
    	auto pf=prime_factor(x);
    	
    	int res=0;
    	for(auto i: pf){
    		int cnt=i.y, t=0;
    		
    		int cur=1;
    		while(cnt-cur>=0){
    			t++;
    			cnt-=cur;
    			cur++;
    		}
    		res+=t;
    	}
    	cout<<res<<endl;
    	
    	return 0;
    }
    

    E

    排序,看看中位数的范围即可。

    #pragma GCC optimize("O3")
    #include<bits/stdc++.h>
    using namespace std;
    #define endl '
    '
    #define debug(x) cerr << #x << ": " << x << endl
    #define pb(a) push_back(a)
    #define set0(a) memset(a,0,sizeof(a))
    #define rep(i,a,b) for(int i=(a);i<=(b);i++)
    #define dwn(i,a,b) for(int i=(a);i>=(b);i--)
    #define ceil(a,b) (a+(b-1))/b
    #define all(x) (x).begin(), (x).end()
    #define INF 0x3f3f3f3f
    #define ll_INF 0x7f7f7f7f7f7f7f7f
    typedef long long ll;
    typedef pair<int,int> PII;
    typedef pair<double,double> PDD;
    
    inline void read(int &x) {
        int s=0;x=1;
        char ch=getchar();
        while(ch<'0'||ch>'9') {if(ch=='-')x=-1;ch=getchar();}
        while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+ch-'0',ch=getchar();
        x*=s;
    }
    
    const int N=2e5+5;
    int L[N], R[N];
    
    int main(){
    	int n; cin>>n;
    	rep(i,1,n) read(L[i]), read(R[i]);
    	
    	sort(L+1, L+1+n), sort(R+1, R+1+n);
    	
    	int a, b, c, d;
    	
    	if(n&1){
    		a=L[n+1>>1], b=R[n+1>>1];
    		cout<<(b>=a? b-a+1: 0)<<endl;
    	}
    	else{
    		a=L[n>>1], b=R[n>>1];
    		c=L[n+2>>1], d=R[n+2>>1];
    		int res=b+d-a-c+1;
    		if(res>0) cout<<res<<endl; else puts("0");
    	}
        return 0;
    }
    

    F

    dp。
    我的想法是 (f(k,i,j)) 表示前 (k) 个选取 (i) 个数,和为 (j) 的方案数,然后一边 dp 一边统计,但这样是 (O(N^3)) 会超时,没有想到什么优化时间的方法 qwq。

    然后题解的方法是用 (f(i,j)) 表示前 (i) 个数凑出和为 (j) 的方案数。有:

    [f(i, j) = 2 imes f(i-1, j) + f(i-1, j-w_i)~~(jgeq w_i) ]

    [f(i, j) = 2 imes f(i-1, j)~~(j < w_i) ]

    实在是没有想到这种滚雪球的方法,学到许多

    #pragma GCC optimize("O3")
    #include<bits/stdc++.h>
    using namespace std;
    #define endl '
    '
    #define debug(x) cerr << #x << ": " << x << endl
    #define pb(a) push_back(a)
    #define set0(a) memset(a,0,sizeof(a))
    #define rep(i,a,b) for(int i=(a);i<=(b);i++)
    #define dwn(i,a,b) for(int i=(a);i>=(b);i--)
    #define ceil(a,b) (a+(b-1))/b
    #define all(x) (x).begin(), (x).end()
    #define INF 0x3f3f3f3f
    #define ll_INF 0x7f7f7f7f7f7f7f7f
    typedef long long ll;
    typedef pair<int,int> PII;
    typedef pair<double,double> PDD;
    
    #define int long long
    
    inline void read(int &x) {
        int s=0;x=1;
        char ch=getchar();
        while(ch<'0'||ch>'9') {if(ch=='-')x=-1;ch=getchar();}
        while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+ch-'0',ch=getchar();
        x*=s;
    }
    
    const int N=3030, mod=998244353;
    
    int n, s;
    int w[N], f[N];
    
    signed main(){
    	cin>>n>>s;
    	rep(i,1,n) cin>>w[i];
    	
    	f[0]=1;
    	rep(i,1,n){
    		dwn(j,s,0){
    			f[j]=(f[j]+f[j])%mod;
    			if(j>=w[i]) f[j]=(f[j-w[i]]+f[j])%mod;
    		}	   
    	}
    	cout<<f[s]<<endl;
    	
        return 0;
    }
    
  • 相关阅读:
    Smart Client Architecture and Design Guide
    Duwamish密码分析篇, Part 3
    庆贺发文100篇
    .Net Distributed Application Design Guide
    New Introduction to ASP.NET 2.0 Web Parts Framework
    SPS toplevel Site Collection Administrators and Owners
    来自Ingo Rammer先生的Email关于《Advanced .Net Remoting》
    The newsletter published by Ingo Rammer
    深度探索.Net Remoting基础架构
    信道、接收器、接收链和信道接受提供程序
  • 原文地址:https://www.cnblogs.com/Tenshi/p/15021925.html
Copyright © 2011-2022 走看看