4.5刷题日记

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;
}

最大比例

明天来,还是看不懂

总结

开会,烦;题写不通,马上到日子了,烦

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值