题解 P4956 【[COCI2017-2018#6] Davor】
题目大意:
考虑到
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <bitset>
using namespace std;
struct FastIO
{
inline FastIO& operator >> (int& x) {
x = 0; char f = 0, ch = getchar();
while(ch > '9' || ch < '0') f |= (ch == '-'), ch = getchar();
while(ch <= '9' && ch >= '0') x = x * 10 + ch - 48, ch = getchar();
return x = (f ? -x : x), *this;
}
inline FastIO& operator >> (long long& x) {
x = 0; char f = 0, ch = getchar();
while(ch > '9' || ch < '0') f |= (ch == '-'), ch = getchar();
while(ch <= '9' && ch >= '0') x = x * 10 + ch - 48, ch = getchar();
return x = (f ? -x : x), *this;
}
inline FastIO& operator >> (double& x)
{
x = 0; char f = 0, ch = getchar();
double d = 0.1;
while(ch > '9' || ch < '0') f |= (ch == '-'), ch = getchar();
while(ch <= '9' && ch >= '0') x=x * 10 + ch - 48, ch = getchar();
if(ch == '.')
{
ch = getchar();
while(ch <= '9' && ch >= '0') x += d * (ch ^ 48), d *= 0.1, ch = getchar();
}
return x = (f ? -x : x), *this;
}
}rin;
int main() {
int n;
rin >> n;
for(int i = 100 ; i >= 1 ; -- i) {//枚举x
int x = 364 * i;
int now = n - x;
if(now < 0) continue;
if((now % 1092 == 0) && (now != 0)) {//判断是否合法
printf("%d\n%d\n", i, now / 1092);//输出解
return 0;
}
}
}