QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#479390 | #249. Miller Rabin 算法 | A_programmer# | Compile Error | / | / | C++17 | 996b | 2024-07-15 17:04:52 | 2024-07-15 17:04:52 |
Judging History
This is the latest submission verdict.
- [2024-07-15 17:04:52]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-07-15 17:04:52]
- Submitted
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int p[8] = {2, 3, 5, 7, 11, 13, 17, 19};
int fpow(ll a, ll b, ll mod)
{
ll ans = 1;
while (b)
{
if (b & 1) ans = ans * a % mod;
a = a * a % mod;
b >>= 1;
}
return ans;
}
bool judge(ll x)
{
ll t = x - 1; int k = 0;
while (!(t & 1)) k++, t >>= 1;
for (int i = 0; i < 8; i++)
{
if (x == p[i]) return true;
ll tmp = fpow(p[i], t, x);
for (int j = 1; j <= k; j++)
{
int nxt = tmp * tmp % x;
if (nxt == 1 && tmp != 1 && tmp != x - 1) return false;
tmp = nxt;
}
if (tmp != 1) return false;
}
return true;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
ll x;
while ((cin >> x) != EOF)
{
if (x == 1) { cout << "N\n"; continue; }
cout << (judge(x) ? "Y\n" : "N\n");
}
return 0;
}
詳細信息
answer.code: In function ‘int main()’: answer.code:44:23: error: no match for ‘operator!=’ (operand types are ‘std::basic_istream<char>::__istream_type’ {aka ‘std::basic_istream<char>’} and ‘int’) 44 | while ((cin >> x) != EOF) | ~~~~~~~~~~ ^~ | | | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} answer.code:44:23: note: candidate: ‘operator!=(int, int)’ (built-in) 44 | while ((cin >> x) != EOF) | ^ answer.code:44:23: note: no known conversion for argument 1 from ‘std::basic_istream<char>::__istream_type’ {aka ‘std::basic_istream<char>’} to ‘int’ In file included from /usr/include/c++/13/regex:68, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:181, from answer.code:1: /usr/include/c++/13/bits/regex.h:1132:5: note: candidate: ‘template<class _BiIter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const sub_match<_BiIter>&)’ 1132 | operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/13/bits/regex.h:1132:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/13/cstdio:42, from /usr/include/c++/13/ext/string_conversions.h:45, from /usr/include/c++/13/bits/basic_string.h:4097, from /usr/include/c++/13/string:54, from /usr/include/c++/13/bitset:52, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52: answer.code:44:26: note: ‘std::basic_istream<char>::__istream_type’ {aka ‘std::basic_istream<char>’} is not derived from ‘const std::__cxx11::sub_match<_BiIter>’ 44 | while ((cin >> x) != EOF) | ^~~ /usr/include/c++/13/bits/regex.h:1212:5: note: candidate: ‘template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)’ 1212 | operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/regex.h:1212:5: note: template argument deduction/substitution failed: answer.code:44:26: note: ‘std::basic_istream<char>::__istream_type’ {aka ‘std::basic_istream<char>’} is not derived from ‘std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>’ 44 | while ((cin >> x) != EOF) | ^~~ /usr/include/c++/13/bits/regex.h:1305:5: note: candidate: ‘template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)’ 1305 | operator!=(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/regex.h:1305:5: note: template argument deduction/substitution failed: answer.code:44:26: note: ‘std::basic_istream<char>::__istream_type’ {aka ‘std::basic_istream<char>’} is not derived from ‘const std::__cxx11::sub_match<_BiIter>’ 44 | while ((cin >> x) != EOF) | ^~~ /usr/include/c++/13/bits/regex.h:1379:5: note: candidate: ‘template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)’ 1379 | operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/regex.h:1379:5: note: template argument deduction/substitution failed: answer.code:44:26: note: mismatched types ‘const std::__cxx11::sub_match<_BiIter>’ and ‘int’ 44 | while ((cin >> x) != EOF) | ^~~ /usr/include/c++/13/bits/regex.h:1473:5: note: candidate: ‘template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)’ 1473 | operator!=(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/regex.h:1473:5: note: template argument deduction/substitution failed: answer.code:44:26: note: ‘std::basic_istream<char>::__istream_type’ {aka ‘std::basic_istream<char>’} is not derived from ‘const std::__cxx11::sub_match<_BiIter>’ 44 | while ((cin >> x) != EOF) | ^~~ /usr/include/c++/13/bits/regex.h:1547:5: note: candidate: ‘template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)’ 1547 | operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/regex.h:1547:5: note: template argument deduction/substitution failed: answer.code:44:26: note: mismatched types ‘const std::__cxx11::sub_match<_BiIter>’ and ‘int’ 44 | while ((cin >> x) != EOF) | ^~~ /usr/include/c++/13/bits/regex.h:1647:5: note: candi...