Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- Online C++ Compiler.
- Code, Compile, Run and Debug C++ program online.
- Write your code in this editor and press "Run" button to compile and execute it.
- *******************************************************************************/
- #include <iostream>
- #include <cmath>
- using namespace std;
- using ll = long long;
- ll a,b;
- ll S(ll x){
- return (2*3 + 3 * (x - 1)) * x / 2;
- }
- bool f(ll N){
- ll c1 = 0;
- bool can = 1;
- if (N == 0){
- c1 = 0;
- }
- else{
- while (true){
- if (S(c1) == N){
- break;
- }
- if (S(c1) > N){
- can = 0;
- break;
- }
- c1++;
- }
- }
- if (can){
- ll c2 = 0;
- if (c1 == 0){
- c2 = 0;
- }
- else{
- while (true){
- if (S(c2) == c1){
- break;
- }
- if (S(c2) > c1){
- can = 0;
- break;
- }
- c2++;
- }
- }
- if (can){
- return c2 == 18;
- }
- else return false;
- }
- else return false;
- }
- int main()
- {
- int x = 0;
- ll ans = -666;
- while (true){
- //cout<<x<<'\n';
- if (x > 4e6) {
- cout<<x<<'\n';
- break;
- }
- if (f(x)) {
- cout<<"x = "<<x<<'\n';
- break;
- }
- x++;
- }
- }
- //Программа может вообще не дойти -- тогда return false
Add Comment
Please, Sign In to add comment