ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#214384 | #2678. Small Multiple | STASISZHY | 100 | 735ms | 22540kb | C++11 | 1.1kb | 2024-11-18 19:32:36 | 2024-11-19 08:28:58 |
answer
// Problem: B. Small Multiple
// Contest: undefined - NOIP2024训练赛 08
// URL: http://www.noi.ac/contest/1160/problem/2678
// Memory Limit: 1024 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
#define fi first
#define se second
#define PII pair<int, int>
using namespace std;
const int N = 1e6 + 10, INF = 0x3f3f3f3f;
int n, m;
bool vis[N], dp[N][55];
list<PII> q;
// void dfs(int now, int sum)
// {
// if()
// if(sum >= 55 || dp[now][sum]) return;
// dp[now][sum] = true;
// for(int i = 0; i < m; i ++) dfs((now * m + i) % n, sum + i);
// }
void bfs()
{
q.push_front({1, 1});
vis[1] = true;
while(!q.empty())
{
int num = q.front().fi, val = q.front().se; q.pop_front();
if(!num)
{
cout << val << '\n';
return;
}
if(!vis[m * num % n])
{
q.push_front({m * num % n, val});
vis[m * num % n] = true;
}
if(!vis[(num + 1) % n])
q.push_back({(num + 1) % n, val + 1});
}
return;
}
signed main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n >> m;
bfs();
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 5
Accepted
time: 0ms
memory: 1256kb
input:
32 4
output:
1
result:
ok single line: '1'
Test #2:
score: 5
Accepted
time: 1ms
memory: 1260kb
input:
25 6
output:
5
result:
ok single line: '5'
Test #3:
score: 5
Accepted
time: 0ms
memory: 1260kb
input:
19 3
output:
2
result:
ok single line: '2'
Test #4:
score: 5
Accepted
time: 0ms
memory: 1256kb
input:
64 7
output:
4
result:
ok single line: '4'
Test #5:
score: 5
Accepted
time: 0ms
memory: 1256kb
input:
86 10
output:
3
result:
ok single line: '3'
Test #6:
score: 5
Accepted
time: 0ms
memory: 1260kb
input:
17 2
output:
2
result:
ok single line: '2'
Test #7:
score: 5
Accepted
time: 83ms
memory: 22540kb
input:
937761 10
output:
6
result:
ok single line: '6'
Test #8:
score: 5
Accepted
time: 9ms
memory: 5088kb
input:
788944 8
output:
4
result:
ok single line: '4'
Test #9:
score: 5
Accepted
time: 43ms
memory: 10744kb
input:
573314 3
output:
4
result:
ok single line: '4'
Test #10:
score: 5
Accepted
time: 51ms
memory: 14292kb
input:
785883 5
output:
2
result:
ok single line: '2'
Test #11:
score: 5
Accepted
time: 72ms
memory: 14152kb
input:
769025 7
output:
6
result:
ok single line: '6'
Test #12:
score: 5
Accepted
time: 29ms
memory: 12752kb
input:
909894 4
output:
3
result:
ok single line: '3'
Test #13:
score: 5
Accepted
time: 92ms
memory: 17824kb
input:
585472 9
output:
8
result:
ok single line: '8'
Test #14:
score: 5
Accepted
time: 4ms
memory: 3028kb
input:
795020 5
output:
4
result:
ok single line: '4'
Test #15:
score: 5
Accepted
time: 11ms
memory: 5776kb
input:
514716 8
output:
3
result:
ok single line: '3'
Test #16:
score: 5
Accepted
time: 80ms
memory: 17596kb
input:
984458 5
output:
4
result:
ok single line: '4'
Test #17:
score: 5
Accepted
time: 52ms
memory: 10960kb
input:
645285 2
output:
4
result:
ok single line: '4'
Test #18:
score: 5
Accepted
time: 118ms
memory: 20884kb
input:
694328 9
output:
8
result:
ok single line: '8'
Test #19:
score: 5
Accepted
time: 31ms
memory: 9220kb
input:
698907 6
output:
2
result:
ok single line: '2'
Test #20:
score: 5
Accepted
time: 59ms
memory: 17756kb
input:
994036 7
output:
2
result:
ok single line: '2'