Acwing第 7 场周赛【未完结】
生活随笔
收集整理的這篇文章主要介紹了
Acwing第 7 场周赛【未完结】
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
目錄
- 3758. 距離零點的時刻 【難度: 簡單 / 知識點: 模擬】
- 3759. 第k個字符串 【難度: 一般 / 知識點: 規律】
3758. 距離零點的時刻 【難度: 簡單 / 知識點: 模擬】
#include<bits/stdc++.h> using namespace std; int main(void) {int t; cin>>t;while(t--){int a,b; cin>>a>>b;cout<<60*24-a*60-b<<endl;}return 0; }3759. 第k個字符串 【難度: 一般 / 知識點: 規律】
#include<bits/stdc++.h> using namespace std; int main(void) {int t; cin>>t;while(t--){int n,k; cin>>n>>k;string s(n+1,'a');int l=0,r=0,step=1;int index=0;for(int i=n-1;i>=1;i--){l=r+1;r=r+step;if(k>=l&&k<=r){index=i;break;}step++;}s[index]='b',s[n-(k-l)]='b';s=s.substr(1);cout<<s<<endl;}return 0; } #include <iostream> #include <cstring> #include <algorithm>using namespace std;int main() {int T;cin >> T;while (T -- ){int n, k;cin >> n >> k;for (int i = n - 1; i; i -- ){if (k > n - i) k -= n - i;else{string s(n, 'a');s[i - 1] = s[n - k] = 'b';cout << s << endl;break;}}}return 0; }總結
以上是生活随笔為你收集整理的Acwing第 7 场周赛【未完结】的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Acwing第 6 场周赛【未完结】
- 下一篇: Acwing第 8 场周赛【未完结】