日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Codeforces Round #719 (A-C)

發布時間:2023/12/10 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Codeforces Round #719 (A-C) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

第一題題意:就是不能回去:

#include<iostream> using namespace std; int main() {int t;cin>>t;while (t--){int n,ch[1001]={0};cin>>n;string str;cin>>str;bool flag = true;ch[str[0]]++;for (int i=1;i<n;i++){if (str[i]!=str[i-1]){if (ch[str[i]]!=0) {flag = false;break;}else{ch[str[i]]++;}}}if (flag == true) cout<<"Yes"<<endl;else cout<<"No"<<endl;} }

第二題:找1-n的回文數字有多少個:

#include<iostream> #include<cstring> #include<algorithm> using namespace std; int main() {int t;cin>>t;while (t--){int n;string str;cin>>n;int gg = n;do{str+=(gg%10+'0');gg/=10;}while (gg!=0);// string str = to_string(n);int len = str.length();int sum = 9*(len-1);int num = 1;for (int i=1;i<len;i++){num = num*10+1;}int tip = num;while (1){if (num>n) break;else {num+=tip;sum++;}}cout<<sum<<endl;} }

第三題:方陣,相鄰數字不能差1
我感覺我寫煩了。

#include<iostream> using namespace std; int main() {int t;cin>>t;while (t--){int n;cin>>n;if (n==2) cout<<-1<<endl;else{int ch[10001]={0};int cou = 1;for (int i=0;i<n*n;i+=2){ch[i] = cou;cou++;}for (int i=1;i<n*n;i+=2){ch[i] = cou;cou++;}cou = 0;while (1){if (cou == n*n) break;for (int i=0;i<n;i++){cout<<ch[cou]<<" ";cou++;}cout<<endl;}}} }

原諒本蒻蒻只寫出來這三題,第五題DP寫法差一點寫出來了,/(ㄒoㄒ)/~~

總結

以上是生活随笔為你收集整理的Codeforces Round #719 (A-C)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。