Блог пользователя ram_0001

Автор ram_0001, история, 5 лет назад, По-английски

problem: CSES coin combinations I Link: https://cses.fi/problemset/task/1635 My code:

include<bits/stdc++.h>

using namespace std; int mod = 1000000007; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n,x; cin >> n >> x; vector coins(n); for (int i = 0; i < n;i++) cin >> coins[i]; vector dp(x + 1, 0); dp[0] = 1; for (int i = 1; i <= x;i++){ for (auto j : coins){ if(i-j>=0) dp[i] = (dp[i] + dp[i — j])%mod; } } cout << dp[x]; return 0; }

  • Проголосовать: нравится
  • -6
  • Проголосовать: не нравится

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

As the bounds are quite large, try to avoid using vectors and use arrays instead.

Also, next time you should put your code in code blocks like this

#include <iostream>
cin>>a;
cout<<a;

or just link us to your submission

»
5 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

give ur code like this on codeforces blogs and comments

Code