-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProfName.cpp
More file actions
45 lines (41 loc) · 717 Bytes
/
ProfName.cpp
File metadata and controls
45 lines (41 loc) · 717 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
45
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;
void toFile(int);
int main()
{
string in;
ifstream fin("chaos.in");
getline(getline(fin, in), in);
fin.close();
vector<int> abcdk;
int n;
istringstream stream(in);
while (stream >> n)
abcdk.push_back(n);
bool tofile = false;
vector<int> a = abcdk;
for (int i = 0; i < abcdk[4]; i++) {
if (a[0] * a[1] < a[2]) {
toFile(0);
tofile = true;
break;
}
else {
if ((a[0] * a[1] - a[2]) > a[3])
a[0] = a[3];
else
a[0] = a[0] * a[1] - a[2];
}
}
if(!tofile)
toFile(a[0]);
}
void toFile(int start) {
ofstream fout("chaos.out");
fout << start;
fout.close();
}