C循环
还是和昨天一样的题型,背就完事了
ll a[maxn];
ll exgcd(ll a, ll b, ll &x, ll &y){
if(!b){
x = 1, y = 0;
return a;
}
int d = exgcd(b, a % b, y, x);
y -= a / b * x;
return d;
}
int main() {
IOS;
// freopen("P1908_6.in","r",stdin);//读入数据
// freopen("P1908.out","w",stdout); //输出数据
ll a, b, c, k;
while(cin >> a >> b >> c >> k){
if(!(a | b | c | k))
break;
ll m = 1ll << k;
ll x, y;
ll d = exgcd(c, m, x, y);
if((b - a) % d){
cout << "FOREVER" << endl;
}
else {//a + cx - y * 2^k = b -> cx - y * 2 ^ k = b - a
x *= (b - a) / d;
m /= d;
cout << (x % m + m) % m << endl;
}
}
return 0;
}
正则问题
递归本质就是树
| : 两者取其一
& : 连接起来
string s;
int len;
int se = 0;
int dfs(){
int ans = 0;
while(se < len){
if(s[se] == '(') {
++se;
ans += dfs();
++se;
}
else if(s[se] == '|') {
++se;
ans = max(ans, dfs());
}
else if(s[se] == ')')
return ans;
else {
++ans;
++se;
}
}
return ans;
}
int main() {
IOS;
// freopen("P1908_6.in","r",stdin);//读入数据
// freopen("P1908.out","w",stdout); //输出数据
cin >> s;
len = s.size();
cout << dfs();
return 0;
}
最大比例
明天来,还是看不懂
总结
开会,烦;题写不通,马上到日子了,烦