-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path13a.cpp
More file actions
51 lines (42 loc) · 724 Bytes
/
13a.cpp
File metadata and controls
51 lines (42 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <algorithm>
#include <set>
#include <sstream>
#include <cmath>
#include <stdlib.h>
using namespace std;
vector<int> nums;
int main(){
string dato;
int marca;
cin>>marca;
while(getline(cin,dato,',')){
if(dato!="x"){
int valor;
string s = dato;
stringstream ss(s);
ss >> valor;
nums.push_back(valor);
}
}
long long menordif=100000000000;
long long res;
for(auto x: nums){
int temp1=floor(marca/x)+1;
int temp2=x-(marca%x);
if(temp1*x<menordif){
menordif=temp1*x;
res=x;
}
}
menordif-=marca;
res*=menordif;
cout<<res<<endl;
/*cout<<marca<<endl;
for(auto x: nums){
cout<<x<<endl;
}*/
}