Codeforces Round #660 (Div. 2) B. Captain Flint and a Long Voyage
生活随笔
收集整理的這篇文章主要介紹了
Codeforces Round #660 (Div. 2) B. Captain Flint and a Long Voyage
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
題目鏈接
思路:
最后要刪除后n位,那肯定是越長越好,二進制里面只有9和8是四位數,而9(1001)比8(1000)更符合刪除后的,所有盡可能取9。
代碼:
#include<bits/stdc++.h> #define int long long #define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); const int N=1e5+5; const int M=2e4+5; const double eps=1e-8; const int mod=1e9+7; const int inf=0x7fffffff; const double pi=3.1415926; using namespace std; signed main() {int t;cin>>t;while(t--){int n;cin>>n;int cnt=n/4;if(n%4!=0){cnt++;}for(int i=0;i<n-cnt;i++){cout<<9;}for(int i=0;i<cnt;i++){cout<<8;}cout<<endl;}return 0; }總結
以上是生活随笔為你收集整理的Codeforces Round #660 (Div. 2) B. Captain Flint and a Long Voyage的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: TextRank算法讲解与代码实现
- 下一篇: 南通大学java期末_【Java爬虫】爬