/ SeriousOJ /

Record Detail

Compile Error

foo.cc: In function 'void done()':
foo.cc:82:36: error: expected ';' before 'else'
   82 |         if(a==b) cout<< a+a-1<<endl
      |                                    ^
      |                                    ;
   83 |                 else cout<<a+a<<endl;
      |                 ~~~~                

Code

#include <iostream>
#include <vector>
#include <utility>
#include <set>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <string>

// ——— TYPE ALIASES ———
using namespace std;
using ll   = long long;
using ull  = unsigned long long;
using ld   = long double;
using pii  = pair<int, int>;
using pll  = pair<ll, ll>;
using vi   = vector<int>;
using vb   = vector<bool>;
using vll  = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using si   = set<int>;
using spii = set<pii>;

// ——— CONSTANTS ———
constexpr int INF_INT = 0x3f3f3f3f;
constexpr ll INF_LL = 4e18;
constexpr ll MOD = 1e9 + 7;
constexpr ll MOD2 = 998244353;
constexpr ld EPS = 1e-9;
constexpr ld PI = acos(-1.0L);

// ——— MACROS ———
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) int((x).size())
#define pb push_back
#define eb emplace_back
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define each(x,v) for(auto &x : v) //range traversal
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)
#define bit(x) bitset<32>(x) //bitset

// ——— MATH ———
ll modexp(ll base, ll exp, ll m) {
    ll res = 1 % m;
    base %= m;
    while (exp > 0) {
        if (exp & 1) res = (res * base) % m;
        base = (base * base) % m;
        exp >>= 1;
    }
    return res;
}

ll gcd_ll(ll a, ll b) {
    return b == 0 ? a : gcd_ll(b, a % b);
}

ll lcm_ll(ll a, ll b) {
    return (a / gcd_ll(a, b)) * b;
}


void done() {
	ll n; cin>>n;
	int a,b;
	
	for(ll i=1; i<=n; i++){
		bool f = true;
		for(int j=i; j<i+2; j++){
			if(i*j <= n){
			a=i,b=j;
			}
			else f=false;
		}
		if(!f) break;
	}
	
	if(a==b) cout<< a+a-1<<endl
		else cout<<a+a<<endl;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T; cin >> T;
    while (T--) done();
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1191 A. Balanced Product
Contest
Brain Booster #10
Language
C++17 (G++ 13.2.0)
Submit At
2025-06-13 16:02:46
Judged At
2025-06-13 16:02:46
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes