感觉三进制不进位加法应该能解决这个问题
用暴力法实现了一下,不知道怎么优化
更新:发现负数处理问题,调试发现直接(unsigned long long)相当于(unsigned long long)(long long),会扩展符号位,要(unsigned long long)(unsigned)才会用零填充高位,坑了。。。已修正
<code class="language-cpp">#include <stdio.h> int main(int argc, char *argv[]) { int count, nums[256]; scanf("%d", &count); for (int i = 0; i < count; i++) scanf("%d", &nums[i]); unsigned long long prevresult = count > 0 ? (unsigned)nums[0] : 0; for (int i = 1; i < count; i++) { unsigned long long prev = 0, result = 0; for (unsigned long long j = 3; j <= 10460353203ull; j *="3)" { unsigned long now="(unsigned)nums[i]" % + prevresult j; result - prev) prev="now;" } printf("%d\n", (int)prevresult); return 0; < code></=></stdio.h></code>
时段 | 个数 |
---|---|
{{f.startingTime}}点 - {{f.endTime}}点 | {{f.fileCount}} |