ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#214379 | #2678. Small Multiple | erican | 70 | 3018ms | 117320kb | C++11 | 1.6kb | 2024-11-18 19:11:46 | 2024-11-19 08:27:29 |
answer
// Problem: I - Escape
// Contest: Virtual Judge - 思维
// URL: https://vjudge.net/contest/670080#problem/I
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// Challenger: Erica N
// ----
//
#include<bits/stdc++.h>
using namespace std;
#define rd read()
#define ull unsigned long long
#define int long long
#define pb push_back
#define itn int
#define ps second
#define pf first
#define rd read()
int read(){
int xx = 0, ff = 1;char ch = getchar();
while (ch < '0' || ch > '9'){
if (ch == '-')ff = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')xx = xx * 10 + (ch - '0'), ch = getchar();
return xx * ff;
}
#define zerol = 1
#ifdef zerol
#define cdbg(x...) do { cerr << #x << " -> "; err(x); } while (0)
void err() {cerr << endl;}
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) {
for (auto v: a) cerr << v << ' ';err(x...);
}
template<typename T, typename... A>
void err(T a, A... x) {
cerr << a << ' ';err(x...);
}
#else
#define dbg(...)
#endif
const int N=1e6+5;
const ull P=137;
const int INF=1e18+7;
/*
策略
*/
int f[N];
struct Node{
int r=0;
int s;
};
queue <Node> q;
signed main(){
int k=rd;
int m=rd;
for(int i=0;i<N;i++)f[i]=INF;
Node cur,cur2;
for(int i=1;i<m;i++){
cur.r=i%k;
cur.s=i;
q.push(cur);
}
while(!q.empty()){
cur2=q.front();
q.pop();
if(f[cur2.r]<=cur2.s)
continue;
f[cur2.r]=cur2.s;
for(int i=0;i<=m-1;i++){
cur.r=(m*cur2.r+i)%k;
cur.s=cur2.s+i;
q.push(cur);
}
}
cout<<f[0];
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 5
Accepted
time: 0ms
memory: 9016kb
input:
32 4
output:
1
result:
ok single line: '1'
Test #2:
score: 5
Accepted
time: 3ms
memory: 9024kb
input:
25 6
output:
5
result:
ok single line: '5'
Test #3:
score: 5
Accepted
time: 0ms
memory: 9016kb
input:
19 3
output:
2
result:
ok single line: '2'
Test #4:
score: 5
Accepted
time: 3ms
memory: 9036kb
input:
64 7
output:
4
result:
ok single line: '4'
Test #5:
score: 5
Accepted
time: 4ms
memory: 9052kb
input:
86 10
output:
3
result:
ok single line: '3'
Test #6:
score: 5
Accepted
time: 0ms
memory: 9016kb
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: 5
Accepted
time: 140ms
memory: 27864kb
input:
573314 3
output:
4
result:
ok single line: '4'
Test #10:
score: 5
Accepted
time: 741ms
memory: 77512kb
input:
785883 5
output:
2
result:
ok single line: '2'
Test #11:
score: 0
Time Limit Exceeded
input:
769025 7
output:
result:
Test #12:
score: 5
Accepted
time: 282ms
memory: 57312kb
input:
909894 4
output:
3
result:
ok single line: '3'
Test #13:
score: 5
Accepted
time: 339ms
memory: 96328kb
input:
585472 9
output:
8
result:
ok single line: '8'
Test #14:
score: 5
Accepted
time: 312ms
memory: 61412kb
input:
795020 5
output:
4
result:
ok single line: '4'
Test #15:
score: 5
Accepted
time: 697ms
memory: 116748kb
input:
514716 8
output:
3
result:
ok single line: '3'
Test #16:
score: 0
Time Limit Exceeded
input:
984458 5
output:
result:
Test #17:
score: 5
Accepted
time: 161ms
memory: 19460kb
input:
645285 2
output:
4
result:
ok single line: '4'
Test #18:
score: 5
Accepted
time: 336ms
memory: 117320kb
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