Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Input... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long n, m, f[(1 << 18) + 10][105], fac[20];
int c[20], cnt[10], tot;
void init() {
while (n) {
int x = n % 10;
c[tot++] = x;
cnt[x]++;
n /= 10;
}
sort(c, c + tot);
fac[0] = 1;
for (int i = 1; i < 20; i++) fac[i] = fac[i - 1] * i;
}
int main() ... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
bool isPrime(long long int n) {
if (n <= 1) return false;
if (n <= 3) return true;
if (n % 2 == 0 || n % 3 == 0) return false;
for (long long int i = 5; i * i <= n; i = i + 6)
if (n % i == 0 || n % (i + 2) == 0) return false;
return true;
}
int m, sz;
vector<i... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;
public class D {
static class Scanner{
BufferedReader br=null;
StringTokenizer tk=null;
public Scanner(){
br=new BufferedReader... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
const int maxn = (1 << 18) + 10;
long long f[maxn][105], N, M, w[20], vis[10];
inline long long read() {
long long f = 1, r = 0;
char c = getchar();
while (!isdigit(c)) {
if (c == '-') {
f = -1;
}
c = getchar();
}
while (isdigit(c)) {
r = 10 * r + c - '0';
c ... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
* @author Don Li
*/
public class RomanNumbers {
int n;
int[] cnt;
void solve() {
char[] a = in.nextToken().toCharArray();
... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
inline vector<int> getDigit(long long n) {
vector<int> d(10);
do {
d[n % 10]++;
n /= 10;
} while (n);
return d;
}
inline size_t lenLong(long long n) {
size_t count = 0;
do {
++count;
n /= 10;
} while (n);
return count;
}
inline long long getL... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long N, M, n;
long long digits[100];
long long dp[1 << 18][100];
int main() {
ios::sync_with_stdio(false);
cin >> N >> M;
for (n = 0; N > 0; n++) {
digits[n] = N % 10;
N /= 10;
}
sort(digits, digits + n, greater<int>());
memset(dp, 0, sizeof(dp));
... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int n, m, l, k, p;
long long f[(1 << 18) + 1][101], ans;
string a;
int lt[20], c[10];
long get(long x, long i) { return (x >> i) & 1; }
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> a >> m;
lt[0] = 1;
for (int i = 1; i <= 18; ++i) {
lt[i] = (lt... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.util.function.Consumer;
public class Solution {
public static void main(String[] args) {
try (PrintWriter out = new PrintWriter(new BufferedOutputSt... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
char s[20];
long long dp[1 << 18][100], f[10];
int main() {
int m;
scanf("%s%d", s, &m);
int n = strlen(s);
for (int i = 0; s[i]; i++) {
s[i] -= '0';
}
dp[0][0] = 1;
for (int i = 0; i < (1 << n); i++) {
for (int j = 0; j < m; j++) {
memset(f, 0, ... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class CF401D{
static int cntOne(int s){
int ret = 0;
while (s>0){
s &= (s-1);
ret ++;
}
return ret;
}
public static void main(String[] args){... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double eps = 1e-10;
const int inf = 0x3f3f3f3f;
const long long infLL = 0x3f3f3f3f3f3f3f3fLL;
const int maxn = 18 + 5;
const int maxs = (1 << 18) + 5;
const int maxm = 100 + 5;
string s;
int n, m;
long long f[maxs][maxm];
int cnt[maxn];
lon... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int len;
int mo;
string n;
long long dp[1 << 18][100];
long long coun[10];
int fastmod[10004];
void pre() {
for (int i = (1); i <= (10004 - 1); ++i) {
fastmod[i] = i % mo;
}
}
inline long long solve(int mask, int m) {
if (mask == (1 << len) - 1) return m == 0;
i... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 18;
long long dp[(1 << N)][105];
string n;
int qwq;
int m, pw[20];
bool used[10];
void init() {
pw[0] = 1;
for (int i = 1; i <= n.size(); i++) pw[i] = pw[i - 1] * 10 % m;
}
int main() {
cin >> n >> m;
dp[0][0] = 1;
init();
for (int i = 1; i < (1 <<... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
char s[25];
int m;
long long ans[1 << 18][105];
long long fac(int n) {
long long out = 1;
for (int i = 1; i <= n; i++) out *= i;
return out;
}
int tool[10];
int main() {
scanf("%s%d", s, &m);
int len = strlen(s... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> ll;
typedef vector<long long> vl;
typedef vector<ll> vll;
typedef vector<vl> vvl;
template <typename T>
ostream &operator<<(ostream &o, vector<T> v) {
if (v.size() > 0) o << v[0];
for (unsigned i = 1; i < v.size(); i++) o << " " << v[i... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long n;
int m;
int ara[20], len;
long long dp[1 << 18][102];
long long func(int mask, int modu) {
if (mask == (1 << len) - 1) {
if (modu == 0) {
return 1;
}
return 0;
}
if (dp[mask][modu] != -1) {
return dp[mask][modu];
}
long long ans =... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &a) {
register int b = 1, c = getchar();
a = 0;
for (; !isdigit(c); c = getchar())
if (c == 45) b *= -1;
for (; isdigit(c); c = getchar()) a = (a << 3) + (a << 1) + c - 48;
a *= b;
}
const int maxn = 105;
const int maxm = 1 <<... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long dp[262144][101];
queue<int> Q;
int K[262144], P[19], A[19];
char S[20];
int main() {
int a, b, t, l, n, la, s;
cin >> S + 1 >> b, dp[0][0] = 1, a = strlen(S + 1), l = (1 << a) - 1,
Q.push(0), n = 1, P[0] = 1 % b;
for (int i = 1; i <= 18;... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int zeros = 0;
long long cnt[1 << 18][100];
int m;
vector<int> digit, summary;
int bitcnt(int i) {
int res = 0;
while (i) {
i >>= 1;
res++;
}
return max(res, 1);
}
int mhash(vector<int> &v) {
int res = 0;
for (int i = 0; i < int(v.size()); ++i) {
res... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.util.*;
public class RomanAndNumbers {
private static long[][]dp;
private static char[]s;
private static int m;
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
s=(""+sc.nextLong()).toCharArray();
m=sc.nextInt();
sc.close();
dp=new long[(int)Math.pow(2,s.length)][m];
... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
public class D {
static char[] ch;
static int m;
static long[][] dp;
static long solve(int mask, int mod, int len) {
if (len == ch.... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;
/**
* @author khokharnikunj8
*/
public class Main {
public static void main(String[] args) {
... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string s;
cin >> s;
int m;
cin >> m;
int n = s.size();
sort(s.begin(), s.end());
int limit = (1 << n);
long long int dp[limit][m];
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
for (int i = 0... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
long long int t, n, m, a[1000005] = {0}, dp[263000][105] = {0};
string s;
vector<long long int> v;
map<long long int, long long int> mp;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
long long int i, j, ... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
bool chk(int msk, int ps) { return (bool)(msk & (1 << ps)); }
int seti(int msk, int ps) { return (msk |= (1 << ps)); }
string str;
int m;
long long int dp[(1 << 18) + 2][101];
vector<int> vt[13];
long long int rec(int msk, int num) {
if (__builtin_popcount(msk) == str.siz... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 |
import java.util.Scanner;
public class Roman {
public static void main(String[] args) {
// TODO code application logic here
String s;
int m;
Scanner sc=new Scanner(System.in);
s=sc.next();
m=sc.nextInt();
int sz=s.length();
int mx=1<<sz;
... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
namespace patch {
template <typename T>
std::string to_string(const T& n) {
std::ostringstream stm;
stm << n;
return stm.str();
}
} // namespace patch
int m, lim, len;
long long dp[1 << 18][101];
string s;
long long fac[19];
int freq[10];
long long solve(int mask, in... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner in = new Scanner(System.in);
String n = in.next();
int m = in.nextInt();
byte[] nums = new byte[10];
for(char ch: n.toCharArray()) {
++nums[Character.digit(ch, 10)];
}
int... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.util.Scanner;
// https://codeforces.com/problemset/problem/401/D
public class VipulAndModulos {
private static int m, l;
private static char[] n;
private static long[][] dp;
private static long solve(int mask, int mod) {
if (mask == (1 << l) - 1)
return mod == 0 ? 1 : 0... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 |
/*
Keep solving problems.
*/
import java.util.*;
import java.io.*;
public class CF401D {
BufferedReader br;
PrintWriter out;
StringTokenizer st;
boolean eof;
final long MOD = 1000L * 1000L * 1000L + 7;
long[][] dp;
char[] arr;
int n;
int m;
void solve() throws IOException {
... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Abood2C {
static int N;
static long memo[][][][][][][][][][][][];
static int MOD;
static... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.IOException;
import java.util.Arrays;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author Mahmoud Aladdin <aladdin3>
*/
public class Main {
public static void ma... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int dig[20];
const int M = 262145;
long long dp[262145][101];
int m;
int pos;
long long dfs(int state, int x) {
long long ans = 0;
if (state == (1 << pos) - 1) return x == 0;
long long &dpAns = dp[state][x];
if (dpAns != -1) return dpAns;
int vis[10] = {0};
for ... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long f[1 << 18][101];
bool bit(int x, int i) { return ((x >> i) & 1); }
int bit1(int x, int i) { return (x | (1 << i)); }
inline long long fac(int k) {
long long ans = 1, i;
for (i = 1; i <= k; i++) {
ans *= i;
}
return ans;
}
int C[100];
int main() {
int... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | /**
* DA-IICT
* Author : PARTH PATEL
*/
import java.io.*;
import java.math.*;
import java.util.*;
import static java.util.Arrays.fill;
import static java.lang.Math.*;
import static java.util.Arrays.sort;
import static java.util.Collections.sort;
public class D401 {
public static int mod = 1000000007;
static Fa... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long dp[1 << 18][100], d, f[20];
int main() {
int m, l, n, i, j, k, c[10];
char a[20];
memset(c, 0, sizeof(c));
for (f[0] = 1, i = 1; i < 20; i++) f[i] = f[i - 1] * i;
scanf("%s%d", a, &m);
l = strlen(a), n = 1 << l;
for (i = 0; i < l; i++) c[a[i] -= '0']... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &a) {
register int b = 1, c = getchar();
a = 0;
for (; !isdigit(c); c = getchar())
if (c == 45) b *= -1;
for (; isdigit(c); c = getchar()) a = (a << 3) + (a << 1) + c - 48;
a *= b;
}
const int maxn = 105;
const int maxm = 1 <<... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
inline char readc() {
char ch = getchar();
while (ch < '0' || ch > '9') ch = getchar();
return ch;
}
char s[20];
int n;
int a[20];
int m;
long long dp[1 << 18][110];
bool vis[10];
int main() {
scanf("%s", s);
n = strlen(s);
for (register int i = 1; i <= n; i++) ... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long a[20], m, dp[100][1 << 18], b[11];
string n;
long long solve(long long sum, long long mask) {
if (mask == (1 << n.size()) - 1) return ((sum % m) == 0);
long long &ret = dp[sum][mask];
if (ret != -1) return ret;
ret = 0;
int u[10] = {0};
for (long long ... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long dp[1 << 18][105];
bool vis[10];
vector<int> a;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
long long n, m;
cin >> n >> m;
while (n > 0) {
int t = n % 10;
a.push_back(t);
n /= 10;
}
int l = a.size();
dp[0][0] = 1;
for (int i ... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
c b, e;
};
template <class c>
rge<c> range(c i, c j) {
return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
template <class c>
debug& operator<<(const c&... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int set_bit(int mask, int c) { return mask |= (1UL << c); }
bool get_bit(int mask, int c) { return (mask >> c) & 1U; }
int fx[] = {1, -1, 0, 0, 1, 1, -1, -1, 0};
int fy[] = {0, 0, 1, -1, 1, -1, 1, -1, 0};
string fn[] = {"D", "U", "R", "L", "DR", "DL", "UR", "UL", "*"};
int ... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 100000 + 100;
long long dp[1 << 18][105];
int main() {
long long n;
int m;
cin >> n >> m;
vector<int> digit;
int bmask = 1;
long long dmask = 1;
int tmp = 0;
while (n) {
digit.push_back(n % 10);
n /= 10;
... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
vector<long long> v;
long long dp[1 << 18][100], n, m;
long long bt(long long mask, long long rem) {
if (mask == (1LL << n) - 1LL) {
if (rem == 0) return 1;
return 0;
}
if (dp[mask][rem] != -1) return dp[mask][rem];
long long ret = 0, i, k;
for (int h = 0;... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
string num;
int m, n;
long long dp[1 << 18][100];
int cnt[10], fact[20];
long long solve(int cnt, int mask, int rem) {
if (cnt == n) {
if (rem == 0) return 1;
return 0;
}
long long &ret = dp[mask][rem];
if (ret != -1) return ret;
ret = 0;
int vis[10];
... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long dp[(1ll << (18)) + 1][100];
long long mod;
long long a[100], cnt[100000];
string s;
signed main() {
cin >> s >> mod;
long long n = s.size();
for (long long i = 0; i < n; i++) {
a[i + 1] = s[i] - '0';
cnt[a[i + 1]]++;
}
dp[0][0] = 1;
for (long l... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.*;
import java.util.*;
public class C implements Runnable{
public static void main (String[] args) {new Thread(null, new C(), "_cf", 1 << 28).start();}
int[] nums;
int n, m;
long[][] dp;
public void run() {
FastScanner fs = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.util.*;
import java.io.*;
public class Maximus1{
public static void main(String [] args)throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
long n = Long.parseLong(st.nextToken());
int m = Integ... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.util.*;
public class D {
private static long solve(long n, int m)
{
long mask = 0;
long[] digMasks = new long[10];
long[] digFullMasks = new long[10];
for (long i = 0, t = 128; i < 10; ++i)
{
digMasks[(int)i] = t;
digFullMasks[(int)i] = t*31;
t <<= 5;
}
long t = n;
int nd... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long dp[1 << 18][100], cnt[10], n, m, l = 0, d[20];
vector<int> masks[20];
long long calc(int mask, int sum) {
if (mask == (1 << l) - 1) return sum == 0;
if (dp[mask][sum] != -1) return dp[mask][sum];
long long res = 0;
bool u[10] = {};... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int cnt[10];
int m;
int mod(int x) {
while (x >= m) x -= m;
return x;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
string n;
cin >> n;
for (auto c : n) {
cnt[c - '0']++;
}
cin >> m;
long long dp[cnt[0] + 1][cnt[1] + 1][cnt[2] + ... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) {
InputStr... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
public class A {
static char [] c;
static int n, m;
static long [][] memo;
static long dp(int z, int mod, int msk){
if(msk == 0)
r... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const long long inf = 1e18;
const long long N = 100001;
long long dp[1 << 18][100];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, k = 0, m;
cin >> n >> m;
long long rem[20], cnt[20];
memset(rem, 0, si... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.*;
import java.util.*;
import java.math.*;
public class Main {
long[][] dp;
char[] str;
int n;
int m;
public void solve() throws IOException{
str = in.next().toCharArray();
n = str.length;
m = in.nextInt();
dp = new long[(int) 1L << n][(int) m]... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
using namespace std;
long long f[(1 << 18)][100];
int a[20];
bool vis[10];
int main() {
long long n;
int m;
while (cin >> n >> m) {
memset(f, 0, sizeof f);
int tot(0);
while (n) {
a[++tot] = n % 10;
n /= 10;
}
memset(vis, 0, sizeof vis)... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
public class CF {
static int mod, N;
static int[] array;
static long[][] memo;
static int[] powpow;
static int[][][] magic;
public static void main(S... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const long long inf = 1e9;
const long long mod = 1e9 + 7;
const int maxn = 1e5 + 10;
char str[20];
int a[20], cal[20];
long long f[1 << 18][100];
int main() {
long long div = 1;
int n, tot_n, i, j, k, m;
scanf("%s%d", str, &m);
n = strlen(st... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.util.Arrays;
import java.util.Scanner;
/**
* Created by ZCMX0557 on 2/4/2016.
*/
public class Main {
static String s;
static int m;
static long [][]dp;
static long solve(int bm, int md) {
if(bm == 0) {
return md == 0 ? 1 : 0;
}
if(dp[md][bm] != -1) {
... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import jav... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long n, f[(1 << 18) + 5][101];
int w[20], b[20], m, cnt;
int main() {
cin >> n >> m;
f[0][0] = 1;
while (n) {
w[++cnt] = n % 10;
n /= 10;
}
for (int j = 1; j < (1 << cnt); ++j) {
memset(b, 0, sizeof(b));
for (int i = 1; i <= cnt; ++i) {
... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long int dp[1 << 18][100] = {0}, s[18];
int main() {
long long int n;
int m, top = 0, maxn, i, j, k;
scanf("%lld%d", &n, &m);
while (n) {
s[top++] = n % 10;
n /= 10;
}
maxn = 1 << top;
dp[0][0] = 1;
for (i = 0; i < maxn; i++) {
int is[10] = ... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
public class l083 {
private static long[] pow10 = new long[19];
public static void main(String[] args) throws Exceptio... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | // practice with rainboy
import java.io.*;
import java.util.*;
public class CF401D extends PrintWriter {
CF401D() { super(System.out, true); }
Scanner sc = new Scanner(System.in);
public static void main(String[] $) {
CF401D o = new CF401D(); o.main(); o.flush();
}
void main() {
long n = sc.nextLong();
int... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10;
long long f[1 << 18][110];
signed main() {
ios::sync_with_stdio(false);
long long n, m;
cin >> n >> m;
vector<long long> a;
while (n) a.push_back(n % 10), n /= 10;
n = a.size();
f[0][0] = 1;
for (long long i = 0; i < (1 << n); i... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 18, maxm = 100, maxl = 1 << 18;
const long long powten[maxn + 5] = {1,
10,
100,
1000,
10000,
... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWri... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<ll>;
const int B = 18;
const int N = 1 << B;
const int M = 100;
vector<vi> dp;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll n, m;
cin >> n >> m;
ll pw = 1;
... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
string num;
long long mod;
long long dp[262144][105];
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> num >> mod;
long long sz = num.size();
sort(num.begin(), num.end());
dp[0][0] = 1;
for (long long mask = 0; mask < (1 << sz); ++mas... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOExcept... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.util.Arrays; import java.util.Scanner; public class cf401d_10DIMENSIONSBABY { static int[] digitcounts = new int[10]; static int len, mod; static long[][][][][][][][][][][] memo; public static long dp(int[] counts, int cmod) { if (memo[counts[0]][counts[1]][counts[2]][counts[3]][counts[4]][counts[5]][counts... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long n, m;
long long dp[1 << 18][100];
int num[10];
int d[19];
int len;
int main() {
cin >> n >> m;
int len = 0;
while (n) {
num[n % 10]++;
d[len++] = n % 10;
n /= 10;
}
long long res = 1;
for (int i = 0; i < 10; i++) {
while (num[i]) {
... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
Input... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;
/**
* @author khokharnikunj8
*/
public class Main {
public static void main(String[] args) {
... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
inline int read() {
int num = 0;
char c = getchar();
if (c == '-') return -read();
while (c >= '0' && c <= '9') {
num = (num << 3) + (num << 1) + c - '0';
c = getchar();
}
return num;
}
inline long long READ() {
long long num = 0;
char c = getchar();... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int MASK = (1 << 18) + 15, M = 128;
long long dp[MASK][M];
long long fact[M], cnt[M];
int m;
string a;
int32_t main() {
ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
cerr << "HELLO WORLD :)\n";
cin >> a >> m;
fact[0] = 1;
for (auto u : a) ... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 100 + 10;
const int M = 3e5 + 100;
const long long int mod = 1e9 + 7;
const long long int inf = 1e16;
long long int pw[22], dp[M][N], a[22];
bool mark[10];
int main() {
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
long long int k;
int m;
... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main{
public static void main(String[] args) {
solve();
}
static int mod;
static int id[];
static Long dp[][] = new Long[100][1 << 19];
private static void solve() {
... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int len;
int mo;
string n;
long long dp[1 << 18][100];
long long coun[10];
int fastmod[10004];
void pre() {
for (int i = (1); i <= (10004 - 1); ++i) {
fastmod[i] = i % mo;
}
}
long long solve(int mask, int m) {
if (mask == (1 << len) - 1) return m == 0;
if (dp[m... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
string s;
int n, m;
long long dp[1 << 18][105];
long long power(int x, int p) {
if (p == 0) return 1;
return x * power(x, p - 1);
}
long long getCount(int mask, int mod, int c) {
if (mask == (1 << n) - 1)
if (mod == 0)
return 1;
else
return 0;
lo... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long dp[1 << 18][100];
int co[1 << 18];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
string s;
cin >> s;
long long m;
cin >> m;
long long n = s.size();
long long c[10];
memset(c, 0, sizeof c);
for (long long i = 0; i < n; i++) c[s[i] - '0'... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long setBit(long long num, long long i) { return num | (1 << i); }
long long unsetBit(long long num, long long i) {
num ^= 1 << i;
return num;
}
bool checkBit(long long num, long long i) {
if (num & 1 << i)
return true;
else
return false;
}
long long bp... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class D {
public static void main(String[] args) {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int tc = 0;
while (true) {
String line = br.rea... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
char s[20];
int m;
long long dp[1 << 18][110];
int cnt[20];
int main() {
ios::sync_with_stdio(false);
cin >> s >> m;
memset(dp, 0, sizeof(dp));
memset(cnt, 0, sizeof(cnt));
dp[0][0] = 1;
int l = strlen(s);
long long x = 1 << l, d = 1;
for (int i = 0; i < l; ... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
public class _D {
static long dp[][],ten[];
static int len,arr[],m;
static long solve(int index, int mod,int mask){
if... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | d = '0123456789ABCDEFGH'
prev = {d[i]: d[i - 1] for i in range(1, 18)}
next = {d[i]: d[i + 1] for i in range(17)}
n, m = raw_input().split()
p, m = ['0'] * 10, int(m)
k, l = 1, len(n)
for x in map(int, n): p[x] = next[p[x]]
a = ''.join(p)
u, v = {a: [0] * m}, {}
u[a][0] = 1
for r in range(1, l + 1):
if r == l an... | PYTHON |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long v;
int n, m;
long long dp[1 << 18][100];
int num[100], cnt[100];
int N;
void solve() {
N = 1 << n;
dp[0][0] = 1;
for (int i = 0; i < n; i++) {
if (num[i] > 0) dp[1 << i][num[i] % m] += 1;
}
for (int i = 1; i < N; i++) {
for (int j = 0; j < m; j++... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 15;
const int inf = 1e9 + 7;
const long long MOD = 1e9 + 7;
double eps = 1e-9;
long long f[20];
int digit[20];
int a[20];
long long dp[1 << 18][105];
int m;
void init() {
f[0] = 1;
for (int i = 1; i <= 18; i++) {
f[i] = f[i - 1] * i;
}
mems... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.InputStreamReader;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.PrintStream;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
import java.io.InputStream;
/**
* Built using CHelper... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
public class D {
static long n;
static int m;
static int cnt_bits(int i) {
int ret=0;
while(i>0) {
... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
long long n, x, dp[1 << 18][100];
int m, p[20], len;
long long dfs(int pos, int status, bool zero, int rev) {
if (!pos) return rev == 0;
if (!zero && dp[status][rev] != -1) return dp[status][rev];
long long ans = 0;
int f[10];
memset(f,... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class CF401D{
public static void main(String[] args){
long[] fact = new long[19];
fact[0] = 1;
for (int i=1; i<19; i++){
fact[i] = fact[i-1]*i;
}
Scanner ... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.HashSet;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class ... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
map<pair<vector<int>, int>, long long> ma;
long long dp[(1 << 18)][101];
int main() {
srand((unsigned int)time(NULL));
long long n, m;
int dig[20], id = 0, ten[20], cnt[10] = {};
ten[0] = 1;
cin >> n >> m;
for (int i = 1; i <= 19; i++) ten[i] = (ten[i - 1] * 10)... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long n;
int m;
long long dp[1 << 18][101];
int num[20];
int c[10];
int digitLen;
long long Fac(int x) { return x == 0 ? 1 : Fac(x - 1) * x; }
int main() {
cin >> n >> m;
while (n) {
int t = (int)(n % 10);
num[digitLen++] = t;
c[t]++;
n /= 10;
}
... | CPP |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 |
import java.io.*;
import java.util.*;
public class Main {
static StringBuilder st = new StringBuilder();
static int n, m, a[];
static long[][][][][][][][][][][][] memo;// idx , taken , mod , zero , one , two , three , four , five , six , seven , eight , nine
static int mult(int a , int b , int MOD) ... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 |
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;
public class D {
int INF = 1 << 28;
//long INF = 1L << 62;
double EPS = 1e-10;
ExMap[] maps;
void run() {
maps = new ExMap[2];
maps[0] = new ExMap(); maps[1] = ne... | JAVA |
401_D. Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.
Number x is considered close to number n mod... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
ifstream fin("A.in");
ofstream fout("A.out");
long long n;
int m, t;
int a[20];
bool upd[10];
long long dp[300000][101];
int main() {
cin >> n >> m;
while (n) {
a[t++] = n % 10;
n /= 10;
}
sort(a, a + t);
for (int i = 0; i < t; ++i) {
if (a[i] && (i ==... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.