diff --git a/S2OJ/1539/1539.cpp b/S2OJ/1539/1539.cpp new file mode 100644 index 00000000..d261cb08 --- /dev/null +++ b/S2OJ/1539/1539.cpp @@ -0,0 +1,54 @@ +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +int t, l, r, a, b, c, ans; +int p, cnt, primes[10000005], sum[10000005]; +bool not_prime[10000005]; + +inline bool check(int x) { + int sum = 0; + + while (x) { + sum += x % 10; + x /= 10; + } + + return !not_prime[sum]; +} + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + for (int i = 2; i <= 10000000; i++) { + if (!not_prime[i]) primes[++p] = i; + + for (int j = 1; j <= p && primes[j] * i <= 10000000; j++) { + not_prime[primes[j] * i] = true; + if (i % primes[j] == 0) break; + } + } + + for (int i = 1; i <= 10000000; i++) { + if (!not_prime[i] && check(i)) sum[i] = sum[i - 1] + 1; + else sum[i] = sum[i - 1]; + } + + cin >> t >> l >> r >> a >> b >> c; + + while (t--) { + ans ^= sum[r] - sum[l - 1]; + + l = ((l ^ b) + a) % c + 1; + r = ((r ^ b) + a) % c + 1; + if (l > r) std::swap(l, r); + } + + cout << ans << endl; + + return 0; +} diff --git a/S2OJ/1539/data/ex_number1.in b/S2OJ/1539/data/ex_number1.in new file mode 100644 index 00000000..cbfe0e3f --- /dev/null +++ b/S2OJ/1539/data/ex_number1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:63a3646abf76b538e977b00851c5907edcfe9e8ae6aa94d666a26cd995c02a2e +size 45 diff --git a/S2OJ/1539/data/ex_number1.out b/S2OJ/1539/data/ex_number1.out new file mode 100644 index 00000000..04dbea43 --- /dev/null +++ b/S2OJ/1539/data/ex_number1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2d9bce94f8f442db287d3041d619cff63d6a842131f8bcab9bc13ea54a950d28 +size 7 diff --git a/S2OJ/1539/data/number1.in b/S2OJ/1539/data/number1.in new file mode 100644 index 00000000..57bb12ea --- /dev/null +++ b/S2OJ/1539/data/number1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dd8ba50e9d6c186de8cf6887b43af070ba4932096d41a04a6274a2f1e131703b +size 28 diff --git a/S2OJ/1539/data/number1.out b/S2OJ/1539/data/number1.out new file mode 100644 index 00000000..c4f3e2c8 --- /dev/null +++ b/S2OJ/1539/data/number1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6482ae52f10140265c025d05fb3d563c175206738a67f9c844abeea5917de660 +size 4 diff --git a/S2OJ/1539/data/number10.in b/S2OJ/1539/data/number10.in new file mode 100644 index 00000000..3b3439bd --- /dev/null +++ b/S2OJ/1539/data/number10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:acfe39b23f1260c765c16c2e54a09dc6b238571da3669cf65c589540754be68e +size 50 diff --git a/S2OJ/1539/data/number10.out b/S2OJ/1539/data/number10.out new file mode 100644 index 00000000..f2e6e10f --- /dev/null +++ b/S2OJ/1539/data/number10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:92ef765a0e90dd86837befb17bf99015d698044eec598ef480737eb1fb8a093e +size 7 diff --git a/S2OJ/1539/data/number2.in b/S2OJ/1539/data/number2.in new file mode 100644 index 00000000..e1c939a0 --- /dev/null +++ b/S2OJ/1539/data/number2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2ab45caf9eebab9741ed7b19cadd514f9b30118677e3f2ef49c4252741b09afd +size 27 diff --git a/S2OJ/1539/data/number2.out b/S2OJ/1539/data/number2.out new file mode 100644 index 00000000..88953db3 --- /dev/null +++ b/S2OJ/1539/data/number2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0e55092af0746630c98d1b2e0d960617c33f8ea7b55739fd18cb7cd5342a28ca +size 3 diff --git a/S2OJ/1539/data/number3.in b/S2OJ/1539/data/number3.in new file mode 100644 index 00000000..e4901c60 --- /dev/null +++ b/S2OJ/1539/data/number3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a8933ff9412f9aff6c428e479a8cfc516743f6dbe0060b9b5403913bd7753166 +size 32 diff --git a/S2OJ/1539/data/number3.out b/S2OJ/1539/data/number3.out new file mode 100644 index 00000000..0e857f18 --- /dev/null +++ b/S2OJ/1539/data/number3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9bc51a62a36433cb57485689ed7adb24de4d51aee294066febe62cf1200939fa +size 4 diff --git a/S2OJ/1539/data/number4.in b/S2OJ/1539/data/number4.in new file mode 100644 index 00000000..842f14e3 --- /dev/null +++ b/S2OJ/1539/data/number4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:85a3ab9695bd71218bd3cf88d1eab36e6b663cf5e5e89dab8b52aaab05df6082 +size 33 diff --git a/S2OJ/1539/data/number4.out b/S2OJ/1539/data/number4.out new file mode 100644 index 00000000..50cdd07d --- /dev/null +++ b/S2OJ/1539/data/number4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:61c3ee4befade66973d99a6ae1d84a1d88c85c04f0a2438c7a105cc4e19ef922 +size 4 diff --git a/S2OJ/1539/data/number5.in b/S2OJ/1539/data/number5.in new file mode 100644 index 00000000..c2364493 --- /dev/null +++ b/S2OJ/1539/data/number5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f43b5484a045517c0bcbf837e931cd708a6f0bb4798cf0d97fdb93b39406dab2 +size 48 diff --git a/S2OJ/1539/data/number5.out b/S2OJ/1539/data/number5.out new file mode 100644 index 00000000..8da733fd --- /dev/null +++ b/S2OJ/1539/data/number5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2646bb5fdd331bd8981384ee31711c45661a6cfc38f3d0af8f6d731efa7f5f87 +size 7 diff --git a/S2OJ/1539/data/number6.in b/S2OJ/1539/data/number6.in new file mode 100644 index 00000000..11d7c2fd --- /dev/null +++ b/S2OJ/1539/data/number6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:935b844a647add0ac9554a9d8ce5d6ec970182ef43ffd858f30c0d693251cc60 +size 48 diff --git a/S2OJ/1539/data/number6.out b/S2OJ/1539/data/number6.out new file mode 100644 index 00000000..be8ace42 --- /dev/null +++ b/S2OJ/1539/data/number6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7be83b9da99223048997eb8b815c7a16a8f10008ee58f9c5a4f0b2658b5efe6f +size 6 diff --git a/S2OJ/1539/data/number7.in b/S2OJ/1539/data/number7.in new file mode 100644 index 00000000..bc6e341a --- /dev/null +++ b/S2OJ/1539/data/number7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1c9a1080fcafb245ae154262ce3cc01ab4ffa816911868c356c753f6c8240037 +size 48 diff --git a/S2OJ/1539/data/number7.out b/S2OJ/1539/data/number7.out new file mode 100644 index 00000000..7ff20b91 --- /dev/null +++ b/S2OJ/1539/data/number7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:78bf47d5661bfdf0e9021190b97afe5149a3ac82229e428ad545c2fb20f0ff89 +size 7 diff --git a/S2OJ/1539/data/number8.in b/S2OJ/1539/data/number8.in new file mode 100644 index 00000000..44b83632 --- /dev/null +++ b/S2OJ/1539/data/number8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f1952023bfca7dbd3e872c3c1a23a2d8658f881d1133dd8cb4b5364388bbba77 +size 50 diff --git a/S2OJ/1539/data/number8.out b/S2OJ/1539/data/number8.out new file mode 100644 index 00000000..cbff7a1b --- /dev/null +++ b/S2OJ/1539/data/number8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8bd3b3518da6c6d9dcabf03813791cd7652bf4cadbf98d56536257bfabe7ebb3 +size 6 diff --git a/S2OJ/1539/data/number9.in b/S2OJ/1539/data/number9.in new file mode 100644 index 00000000..70575419 --- /dev/null +++ b/S2OJ/1539/data/number9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e295b490c65403606b2174a0e9a12f120c73081954571cbecaa2a5039df18e73 +size 50 diff --git a/S2OJ/1539/data/number9.out b/S2OJ/1539/data/number9.out new file mode 100644 index 00000000..57348c19 --- /dev/null +++ b/S2OJ/1539/data/number9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab50204a2b8c51dc9a61fa47d95ef8cdd6228c50586488cb54a9847b6a70f508 +size 6 diff --git a/S2OJ/1539/data/problem.conf b/S2OJ/1539/data/problem.conf new file mode 100644 index 00000000..1ffd31b2 --- /dev/null +++ b/S2OJ/1539/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:497c74a9d5c76854049a3ea783861e54901ec5ae4b5c70aa4f59002bfabf2486 +size 181