(试写一篇牛客博客,,,,看看体验感。。。)
wc,牛客的链接操作好sao啊~~~~~~
问题虫洞——A:https://ac.nowcoder.com/acm/contest/887/A
黑洞内窥:
给出一个"01"串,如果一个字符串在循环旋转中具有最小的词典编纂顺序,那么它就是完美的。
然后要求你切割“01”串,使得局部完美并输出(当然如果是整个串都完美的话。。就不需要切割了)
思维光年:
暴力,超级暴力;
ACcode:(贴上队友的暴力code。。。)
#include<bits/stdc++.h>
using namespace std;
string s,a[100],b[100];
int x,n,T,len;
int s0,s1,min0,x0,x1,max1;
int work(int x)
{
if(s[x] == '1')
{
while(s[x] == '1') x++;
return x - 1;
}
s0 = s1 = 0;
while(s[x] == '0' && x < len) x++,s0++;
while(s[x] == '1' && x < len) x++,s1++;
min0 = s0;
max1 = s1;
n = x - 1;
while(1)
{
x0 = x1 = 0;
while(s[x] == '0' && x < len) x++,x0++;
while(s[x] == '1' && x < len) x++,x1++;
if(!x1) return n;
if(s0 > x0) ///0的个数小于起始段
{
n = x - 1;
min0 = min(min0,x0);
max1 = max(max1,x1);
continue;
}
if(s0 == x0) ///0的个数小于起始段
{
if(x1 > s1) ///1的个数大于起始段
{
n = x - 1;
max1 = max(max1,x1);
continue;
}
else if(x1 < s1) return n;
else
{
if(min0 < x0 || max1 > x1) return n;
else
{
n = x - 1;
continue;
}
}
}
else return n;
}
}
bool check(string a)
{
int lena = a.size();
string b = a;
a += a;
for(int i = 0;i < lena; ++i)
if(a.substr(i,lena) < b) return 0;
return 1;
}
int main()
{
scanf("%d",&T);
while(T--)
{
cin>>s;
len = s.size();
x = 0;
int t = 0;
while(x < len)
{
n = work(x);
++t;
a[t] = "";
for(int i = x;i <= n; ++i) a[t] += s[i];
x = n + 1;
}
int tot = 0;
for(int i = 1;i <= t; ++i)
{
int k = i + 1;
string ans = a[i];
while(k <= t && a[k] == a[i]) ans += a[k],a[k++] = "";
b[++tot] = ans;
i = k - 1;
}
for(int i = 1;i <= tot; ++i)
{
while(b[i] == "") i++;
int j = i + 1;
while(j <= tot && check(b[i] + b[j]))
{
b[i] += b[j];
b[j] = "";
j++;
}
i = j - 1;
}
bool flag = 0;
for(int i = 1;i <= tot; ++i)
if(b[i] != "")
{
if(flag) printf(" "); flag = 1;
cout<<b[i];
}
printf("\n");
}
return 0;
}
/**
1110001110011100111100111000111
0001110001110011
*/ 思维光年:
首先,题目没有说可以是实数因式。。。。
所以,问题就变成了:n次方多项式有没有零点。。。
因为我们知道:对于一个多项式来说,如果它存在零点的话,则其总能写出(x - x0) *( ......) [其中x0为零点] 的形式,
而我们知道,二次函数是可能不存在零点的(b^2 - 4*a*c < 0) ,
而其它n次方多项式在求导之后,其导函数的图像就是(n-1)次方的多项式的图像。。。
固,只有出现二次函数的
<0 时不会出现零点,,,
特判一下,ac~~~~~
ACcode:
#include<bits/stdc++.h>
using namespace std;
int T,n;
int x[30],a,b,c;
int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
for(int i = 0;i <= n; ++i) scanf("%d",&x[n - i]);
if(n < 2) printf("Yes\n");
else if(n > 2) printf("No\n");
else
{
a = x[2]; b = x[1]; c = x[0];
if(b * b - 4 * a * c < 0) printf("Yes\n");
else printf("No\n");
}
}
return 0;
} 
京公网安备 11010502036488号