标签:href lcs str acm ret length asd cpp 暴力
abc
bca
wad
ad
as
asd
wa
aw
wa
wwa
bc
ad
as
a
暴力呀!暴力呀!暴力呀!!!(我真是白学了ORZ)
#include <bits/stdc++.h>
using namespace std;
int main(){
string a,b;
while(cin >> a >> b){
bool judge = false;
int cnt=0;
for(int i=0; i < a.length(); i++){
if(judge){
if (a[i] != b[cnt])
judge = false;
}
if(a[i] == b[cnt]){
judge = true;
cnt++;
}
}
if(judge)
for(int i=0;i < cnt; i++)
cout << b[i];
else
cout << "\"NULL!\"";
cout << endl;
}
return 0;
}
2
10
12
No solution
12=2*2*3
暴力呀!!!暴力呀!!!暴力呀!!!(我真是白学了ORZ ORZ)
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
int a,b,c;
for(int i = 2; i < n; i++)
if(n % i == 0)
{
int m = n / i;
for(int j = i; j <= m / j + 1; j++)
if(m % j == 0 && j <= m / j)
if(m/j - i < cmp)
a = i, b = j, c = m/j, cmp = m/j - i;
}
if (judge == n)
cout << "No solution" << endl;
else
cout << n << "=" << a << "*" << b << "*" << c << endl;
}
return 0;
}
2
3 3
010
010
3 3
011
011
Sad
Happy
水题,只需要判断四个角是否能够有出路和入路即可
#include <bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
int n,m;
cin >> n >> m;
string a,b;
cin >> a >> b;
bool judge=false;
if(a[0] == '0'&&b[m-1] == '0')
judge = true;
if(a[0] == '1'&&b[0] == '0')
judge = true;
if(a[n-1] == '0'&&b[m-1] == '1')
judge = true;
if(a[n-1] == '1'&&b[0] == '1')
judge = true;
if(judge)
cout << "Sad" << endl;
else
cout << "Happy" << endl;
}
return 0;
}
我知道了,我收拾收拾马上滚ORZ
标签:href lcs str acm ret length asd cpp 暴力
原文地址:https://www.cnblogs.com/cafu-chino/p/11877868.html