4 条题解
-
0
随机数大法
#include <iostream> #include <stack> #include <cmath> #include <time.h> #include <stdlib.h> #include <vector> #include <string.h> #include <queue> #include <stdio.h> #include <iomanip> #include <cstdio> #include <algorithm> #define LL long long #define double long double using namespace std; const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; signed main() { int minn = 0, maxx = 1; int n;; cin >> n; srand((unsigned)time(NULL)); int ans; while(n--) { ans = (rand() % (maxx - minn + 1)) + minn; } if(ans == 1) { puts("Yes"); } else { puts("No"); } return 0; }
-
0
其实很简单,善用STL
思路
使用
string
类型自带的比较功能进行比较。ACCODE
#include<bits/stdc++.h> using namespace std; int n;string a[205],b[205]; int main(){ cin>>n;getchar(); for(int i=1;i<=n;i++)getline(cin,a[i]); for(int i=1;i<=n;i++)getline(cin,b[i]); for(int i=1;i<=n;i++){ if(a[i]!=b[i]){ cout<<"No";return 0; } } cout<<"Yes"; return 0; }
-
0
#include<iostream> #include<string> #include<cstring> using namespace std; string a[1001],b[1001]; int main(){ int n; cin>>n; getline(cin,a[0]); for(int i=1;i<=n;i++){ getline(cin,a[i]); } for(int j=1;j<=n;j++){ getline(cin,b[j]); } for(int i=1;i<=n;i++){ int x=a[i].size(); int y=b[i].size(); // cout<<a[i]<<" "<<b[i]<<endl; if(x!=y){ cout<<"No"; return 0; } for(int j=0;j<x;j++){ if(a[i][j]!=b[i][j]){ // cout<<a[i][j]<<" "<<b[i][j]<<endl; cout<<"No"; return 0; } } } cout<<"Yes"; }
- 1
信息
- ID
- 57
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 7
- 标签
- 递交数
- 20
- 已通过
- 8
- 上传者