2.9-2.16 week 3

2.9-2.16 week 3

  1. 前言

  2. 补题

    1. SMU Winter 2025 Round 10
    2. SMU Winter 2025 Round 12

    1.前言

    非常抱歉因为肠胃炎带肠胃感冒休息了两天在医院打点滴来着,提醒大家菠萝和牛奶相克(还有冰可乐)

    2.补题

    1.SMU Winter 2025 Round 10


    D.Unnatural Language Processing

    ​ 题意:分割字符按照他给的两种情况。

    ​ 思路:将a、e看成0,b、c、d看成1。整个单词变成了一个01串,然后发现:当连续的两个1出现时,前一个1需要放到前面的音节结尾。当只有一个连续的1,那么这个1就是音节的开头。然后模拟整个过程就行。

    #include<bits/stdc++.h>
    using namespace std;
    #define int long long
     void solve(){
       int m,s;cin>>m>>s;
       int arr[m+5]={0},count=0;
       for(int i=0;i<m;i++){
         cin>>arr[i];
       }
       sort(arr,arr+m);
       int isuse[arr[m-1]+5]={0};
       for(int i=0;i<m;i++){
         isuse[arr[i]]++;
       }
       for(int i=1;i<=arr[m-1];i++){
         if(isuse[i]==0){
           count+=i;
         }
       }
       if(count>s){
         cout<<"NO\n";return;
       }
       else{
         s-=count;
         int temp=arr[m-1]+1;
         while(s>0){
           s-=temp;
           temp++;
         }
         if(s==0){
           cout<<"YES\n";return;
         }else cout<<"NO\n";return;
       }
     }
     signed main() {
       ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
       int t;cin>>t;
       while(t--){
         solve();
       }
    
       
    
       return 0;
     }
    

    2.SMU Winter 2025 Round 12


    C.Vlad and a Sum of Sum of Digits

    ​ 题意:询问每一位上数字相加总和。

    ​ 思路:预处理和前缀和。

    #include<bits/stdc++.h>
    using namespace std;
    #define endl '\n'
    #define int long long
    typedef long long ll;
    const int maxn=2e5+5;
    int T,n;
    ll a[maxn];
    ll f(int x){
    	int tmp=0;
    	while(x){
    		tmp+=x%10;
    		x/=10;
    	}
    	return tmp;
    }
    signed main() {
    	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    	for(int i=1;i<=2e5;i++)
    		a[i]=a[i-1]+f(i);
    	cin>>T;
    	while(T--){
    		cin>>n;
    		cout<<a[n]<<endl;
    	}
    	return 0;
    }
    

posted @ 2025-02-16 22:54  kktwistz  阅读(9)  评论(0)    收藏  举报
一飞冲天按钮^^