进食后人(100ptsWA掉Hack)
查看原帖
进食后人(100ptsWA掉Hack)
1439183
Burning_Red楼主2025/7/20 11:44

注意看代码的最外层while循环的条件

while (o && i > 0) {
		if (o >= book[i]) {
			o -= book[i];
			t = i;
			while (book[i] > 0) {
				if (book[i] & 1) {
					ans *= t;
					ans %= mod;
				}
				t = t * t;
				t %= mod;
				book[i] >>= 1;
			}
		} else {
			t = i;
			while (o > 0) {
				if (o & 1) {
					ans *= t;
					ans %= mod;
				}
				t = t * t;
				t %= mod;
				o >>= 1;
			}
		}
		i -= 2;
	}

如果你写成了

while (o && i) {

那就完了

因为i一直是奇数,只会从1变成-1,不存在变为0的情况

2025/7/20 11:44
加载中...