UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#214364#2678. Small MultipleSTASISZHY401753ms46520kbC++11806b2024-11-18 18:47:032024-11-19 08:26:13

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 dp[N][55];
 
void dfs(int now, int sum)
{
	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);
}

signed main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for(int i = 1; i < m; i ++) dfs(i, i);
	for(int i = 1; i <= 55; i ++) if(dp[0][i]) {cout << i << '\n'; return 0;}
	return 0;
}

详细

小提示:点击横条可展开更详细的信息

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: 0ms
memory: 1260kb

input:

25 6

output:

5

result:

ok single line: '5'

Test #3:

score: 5
Accepted
time: 0ms
memory: 1280kb

input:

19 3

output:

2

result:

ok single line: '2'

Test #4:

score: 5
Accepted
time: 0ms
memory: 1260kb

input:

64 7

output:

4

result:

ok single line: '4'

Test #5:

score: 5
Accepted
time: 1ms
memory: 1288kb

input:

86 10

output:

3

result:

ok single line: '3'

Test #6:

score: 5
Accepted
time: 1ms
memory: 1264kb

input:

17 2

output:

2

result:

ok single line: '2'

Test #7:

score: 0
Time Limit Exceeded

input:

937761 10

output:


result:


Test #8:

score: 0
Time Limit Exceeded

input:

788944 8

output:


result:


Test #9:

score: 0
Time Limit Exceeded

input:

573314 3

output:


result:


Test #10:

score: 0
Time Limit Exceeded

input:

785883 5

output:


result:


Test #11:

score: 0
Time Limit Exceeded

input:

769025 7

output:


result:


Test #12:

score: 0
Time Limit Exceeded

input:

909894 4

output:


result:


Test #13:

score: 5
Accepted
time: 786ms
memory: 46520kb

input:

585472 9

output:

8

result:

ok single line: '8'

Test #14:

score: 0
Time Limit Exceeded

input:

795020 5

output:


result:


Test #15:

score: 0
Time Limit Exceeded

input:

514716 8

output:


result:


Test #16:

score: 0
Time Limit Exceeded

input:

984458 5

output:


result:


Test #17:

score: 0
Time Limit Exceeded

input:

645285 2

output:


result:


Test #18:

score: 5
Accepted
time: 965ms
memory: 44600kb

input:

694328 9

output:

8

result:

ok single line: '8'

Test #19:

score: 0
Time Limit Exceeded

input:

698907 6

output:


result:


Test #20:

score: 0
Time Limit Exceeded

input:

994036 7

output:


result: