Problem:
Problem H:
Hedro's Hexahedron
Dr. Hedro is astonished.  According to his theory, we can make sludge that can dissolve almost everything on the earth.  Now he's trying to produce the sludge to verify his theory.
The sludge is produced in a rectangular solid shaped tank whose size is
N
×
N
× 2.  Let coordinate of two corner points of tank be (-
N
/2, -
N
/2, -1), (
N
/2,
N
/2, 1) as shown in Figure 1.
Figure 1
Doctor pours liquid that is ingredient of the sludge until height of the liquid becomes 1.  Next, he get a lid on a tank and rotates slowly, without ruffling, with respect to
z
axis (Figure 2).  After rotating enough long time, sludge is produced.  Volume of liquid never changes through this operation.
Figure 2
Needless to say, ordinary materials cannot be the tank.  According to Doctor's theory, there is only one material that is not dissolved by the sludge on the earth.  Doctor named it finaldefenceproblem (for short, FDP).  To attach FDP tiles inside the tank allows to produce the sludge.
Since to produce FDP is very difficult, the size of FDP tiles are limited to 1 * 1.  At first, doctor tried to cover entire the entire inside of the tank.  However, it turned out that to make enough number FDP tiles that can cover completely is impossible because it takes too long time.  Therefore, he decided to replace FDP tiles where an area the sludge touches is zero with those of ordinary materials.  All tiles are very thin, so never affects height of the sludge.
How many number of FDP tiles does doctor need?  He has imposed this tough problem on you, his helper.
Input
Input file contains several data sets.
Each data set has one integer that describes
N
.
Input ends when
N
= 0.  You should output nothing for this case.
Output
For each data set, print the number of tiles in a line.
Constraints
Judge data consists of at most 150 datasets.
2 ≤
N
≤ 10
12
N
is even number
Sample Input
2
4
0
Output for the Sample Input
24
64

Submitted solutions:

code_snippet: /*
 * Author: tender
 * Created Time:  2011/9/5 13:02:29
 * File Name: h.cpp
 */
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;
const double pi = acos(-1.0);
int main() {
    long long ans, x, y, n;
    int flag;
    while(scanf("%lld", &n), n) {
        ans = 8 * n + 2 * (4 * n - 4);
        //printf("ans = %lld\n", ans);
        n /= 2;
        long long tmp = 0;
        long long end = sqrt(double(n));
        for (x = 1; x <= end; x++) {
            tmp += n / x;
            if (n % x == 0) tmp--;
        }
        //printf("tmp = %lld\n", tmp);
        tmp -= end * end;
        if (end * end == n) {
            flag = 1;
            tmp++;
        }
        else
            flag = 0;
        //printf("tmp = %lld\n", tmp);
        tmp = tmp * 2 + end * end - flag;
        tmp *= 8;
        //printf("tmp = %lld\n", tmp);
        ans += tmp;
        printf("%lld\n", ans);
    }
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3448
final_rank: 13

code_snippet: #include <cmath>
#include <vector>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <set>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <climits>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <memory>
#include <functional>
#include <cfloat>
#include <numeric>
#include <random>
#include <sstream>
#include <bitset>
#include <complex>
#include <chrono>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

long long int solve(const long long int n);

int main() {
	long long int n;
	while (std::cin >> n) {
		if (n == 0) break;
		const auto result = solve(n);
		std::cout << result << '\n';
	}
}
long long int solve(const long long int n) {
	const auto half = n / 2;
	const int sqrt = std::sqrt(half);
	long long int result = n - 1;
	for (auto x = 1; x <= sqrt; ++x) {
		const auto y = half / x;
		auto count = y - x;
		if (x * y != half) {
			++count;
		}
		if (count > 0) {
			result += count * 2 - 1;
		}
	}
	result += n;
	result <<= 3;
	return result;
}
accuracy: 1
time_ms: 20
memory_kb: 3328
final_rank: 12

code_snippet: #include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<typeinfo>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;






int main(){
    ll n;
    while(cin>>n && n){
        ll count=n/2;
        ll i;
        for(i=1;i*i<n/2;i++){
            count+=(n/2+i-1)/i;
        }
        cout<<((((count*=2)-=i*i)*=8)+=2*4*n)<<endl;
    }
    
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3092
final_rank: 10

code_snippet: #include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  while(cin>>n,n){
    Int cnt=n/2,i;
    for(i=1;i*i<n/2;i++) cnt+=(n/2+i-1)/i;
    cnt=cnt*2-i*i;
    cout<<(cnt+n)*8<<endl;
  }
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3012
final_rank: 8

code_snippet: #include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  while(cin>>n,n){
    Int cnt=n/2,i;
    for(i=1;i*i<n/2;i++) cnt+=(n/2+i-1)/i;
    cnt=cnt*2-i*i;
    cnt+=n;
    cout<<cnt*8<<endl;
  }
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3072
final_rank: 9

code_snippet: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll N;

void func(){

	ll num1 = 4*2*N;
	ll num2 = 2*(4*N-4);
	ll num3 = 0;
	ll x;

	for(x = 1; x*x < N/2; x++){
		num3 += (N+2*x-1)/(2*x)-1;
	}
	num3 = 2*num3-(x-1)*(x-1);
	num3 *= 8;

	printf("%lld\n",num1+num2+num3);
}

int main(){

	while(true){
		scanf("%lld",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 3144
final_rank: 16

code_snippet: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld =long double;
const ld eps = 1e-9;

bool solve(bitset<18>bs, vector<vector<int>>&dp,const vector<pair<int,int>>&vs,const int now) {
	if(dp[now][bs.to_ulong()]!=-1)return dp[now][bs.to_ulong()];

	bool ok = false;
	if(bs.count()==vs.size())ok=true;
	else {
		for (int i = 0; i < vs.size(); ++i) {
			if (bs[i]) {

			}
			else {
				if (vs[i].first == now || now == 7) {
					bs[i] = true;
					bool aok = solve(bs, dp, vs, vs[i].second);
					if (aok)ok = true;
					bs[i] = false;
				}
				if (vs[i].second == now || now == 7) {
					bs[i] = true;
					bool aok = solve(bs, dp, vs, vs[i].first);
					if(aok)ok=true;
					bs[i] = false;
				}
			}
		}
	
	}
	return dp[now][bs.to_ulong()]=ok;
}
int main()
{
	long long int N;
	while (cin >> N) {
		if(!N)break;
		N/=2;
		vector<int>v;
		v.push_back(N);
		long long int ans=N;
		long long int x=1;
		for (; x < sqrt(N); ++x) {
			v.push_back((N+x-1)/x);
			ans+=(N+x-1)/x;
		}

		for (long long int y = sqrt(N)+1; y >= 2; --y) {
			long long int l=(N+y-1)/y;
			long long int r=(N+y-2)/(y-1);
			l=max(l,x);

			ans+=static_cast<long long int>(y)*(r-l);
			/*for (int k = l; k < r; ++k) {
				v.push_back(y);
			}*/
		}
		ans*=8;
		ans+=4*N*4;
		cout<<ans<<endl;
		
	}
	return 0;
}
accuracy: 1
time_ms: 80
memory_kb: 9680
final_rank: 20

code_snippet: #include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
  long long int N;
  while(cin >> N, N){
    long long int ans = 0, t = ceil(sqrt(N/2.0));
    for(long long int i = 1; i < t; ++i){
      ans += (long long)ceil((double)N/2/i)*2;
    }
    ans += N;
    ans -= t*t;
    ans *= 8;
    ans += 8*N;
    cout << ans << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3064
final_rank: 1

code_snippet: #include <iostream>
#include <cmath>
using namespace std;
typedef long long int lli;

int main(){
    while(1){
        lli n;
        cin >> n;
        if(n==0) break;
        
        lli ans = 2*n*n +8*n;
        n /= 2;
        lli sqrtn = ceil(sqrt(n));
        ans -= (n-sqrtn)*(n-sqrtn) *8;
        for(lli i=1; i<sqrtn; i++){
            ans -= ( n -(n+i-1)/i ) *16;
        }
        cout << ans << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 2984
final_rank: 7

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long int lli;
double EPS = 1e-8;

lli solve(lli n){
    lli total = 2*n*n +8*n;
    lli s = n/2;
    lli rem = 0;
    lli sqrts = ceil(sqrt((long double)s));
    rem += (s-sqrts)*(s-sqrts);
    for(lli i=1; i<sqrts; i++){
        rem += ( s - (s+i-1)/i ) *2;
    }
    return total -rem*8;
}

int main(){
    while(1){
        lli n;
        cin >> n;
        if(n==0) break;
        cout << solve(n) << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3136
final_rank: 11

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	while(true){
		ll n;	cin>>n;
		if(n==0) 	return 0;
		ll ans=8*n;// 底面積
		ll ans2=n/2;
		ll w=1;
		for(;w*w<n/2;w++){
			ans2+=(n+2*w-1)/(2*w);
		}
		ans2=2*ans2-w*w;
		if(n&1)	ans2++;
		ll s=ans+ans2*8;
		cout<<s<<endl;
	}
}
accuracy: 1
time_ms: 30
memory_kb: 1156
final_rank: 2

code_snippet: #include <bits/stdc++.h>
using namespace std;

__int128 N;
__int128 f(__int128 x){
	return (N+2*x-1) / (2*x);
}

__int128 s1(long long N){
	__int128 sum = 0;
	long long T= sqrt(N/2) - 1e-10;
	T++;
	__int128 now = N/2;
	for(long long i = 1 ; i <= T ; i++){
		sum += N/2 - now;
		sum += N/2 - now;
		now = f(i);
	}
	sum += (__int128)(N/2-T) * (N/2-T);
	
	return sum;
}

int main(){
	long long N_;
	while( cin >> N_ && N_ ){
		N = N_;
		__int128 sum = s1(N);
		__int128 result = 4*(2*N)+2*N*N-8*sum;
		string s;
		while( result > 0 ){
			s = string(1,'0'+(int)(result%10)) + s;
			result /= 10;
		}
		cout << s << endl;
		
	}
}
accuracy: 1
time_ms: 50
memory_kb: 1208
final_rank: 17

code_snippet: #include<stdio.h>
int main(){
	long long n;
	while(1){
		scanf("%lld",&n);
		if(n==0)break;
		long long i;
		long long ans=0;
		long long k=n/2;
		for(i=1;i*i<k;i++){
			ans+=((k-1)/i+1)-(i+1);
		}
		ans=(ans+n/2-1)*2+i;
		ans=(ans+n)*8;
		printf("%lld\n",ans);
	}
	return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 1028
final_rank: 14

code_snippet: #include<cstdio>

using namespace std;

typedef long long ll;

int main(){
	for(ll n;scanf("%lld",&n),n;){
		ll ans1=4*2*n; // 奥行き
		ll ans2=4*n-4; // 一番外側の幅 1 の部分

		ll ans3=0,x; // 左下 1/4 の ans2 を除いた部分
		for(x=1;x*x<n/2;x++) ans3+=(n+2*x-1)/(2*x)-1;
		ans3=2*ans3-(x-1)*(x-1);

		printf("%lld\n",ans1+2*(ans2+4*ans3));
	}

	return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 1028
final_rank: 14

code_snippet: #include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long lli;

int main() {
  lli N;
  while(cin >> N && N) {
    lli sq = ceil(sqrt(N*2)/2.0);
    lli sum = 0;
    for(lli x = 1; x < sq; ++x) {
      sum += (lli)ceil((double)N/(2.0*x));
    }
    cout << N*8 + (sum*8 - sq*sq*4 + 4 + N*4-4)*2 << endl;;
  }
  return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 1160
final_rank: 3

code_snippet: #include<iostream>
#include<cmath>

using namespace std;

double Calculate(double n);

int main(){
  double n, sum;
  while(1){
    cin >> n;
    if(n == 0) break;
    sum = Calculate(n/2);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(0);
    cout << sum << endl;
  }
  return 0;
}

double Calculate(double n){
  double i, m, x, y, sum;

  if(modf(sqrt(n), &m) != 0) ++m;
  if(m == n){
    m = 2*n;
    return 2*m*m + 8*m;
  }
  for(i=m-1, y=m, sum=0; i>=1; --i){
    if(modf(n/i, &x) != 0) ++x;
    sum += (i+1)*(x-y);
    y=x;
  }
  return 8*(m*m + 2*sum) + 16*n;
}
accuracy: 1
time_ms: 30
memory_kb: 1280
final_rank: 5

code_snippet: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef long long ll;

int main() {
  ll n;
  while(scanf("%lld",&n),n) {
    ll corner = 1;
    while(corner*corner<n/2) ++corner;
    ll side = n/2;
    for (ll i=1; i*i<n/2; ++i) side += (n/2+i-1)/i;
    side -= corner*corner;
    //cout << corner << " " << side << endl;
    ll ans = side*8+corner*corner*4;
    ans *= 2;
    ans += n*2*4;
    printf("%lld\n",ans);
  }
}
accuracy: 1
time_ms: 30
memory_kb: 1188
final_rank: 4

code_snippet: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <queue>
using namespace std;
#define SZ(v) ((int)(v).size())
const int maxint = -1u>>1;

long long n;

long long gao(long long x) {
    // find p1 * p2 < x
    long long res = 0;
    for (long long p1 = 1; p1 * p1 < x; ++p1) {
        res += ((x - 1) / p1) * 2;
        //printf ("add %I64d\n", ((x - 1) / p1) * 2);
    }
    long long sres = (long long)sqrt((double)x - 1.0);
    //printf ("sub %I64d\n", sres * sres);
    return (res - sres * sres) * 8;
}

int main() {
    while (scanf ("%lld", &n), n) {
        long long ans = n * 8 + (n - 1) * 8;
        printf ("%lld\n", ans + gao(n >> 1));
    }
    return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 0
final_rank: 6

code_snippet: /*
 * Author: Dumbear
 * Created Time:  2011/8/31 14:29:36
 * File Name: H.cpp
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
#define out(v) cerr << #v << ": " << (v) << endl
#define SZ(v) ((int)(v).size())
const int maxint = -1u>>1;
template <class T> bool get_max(T& a, const T &b) {return b > a? a = b, 1: 0;}
template <class T> bool get_min(T& a, const T &b) {return b < a? a = b, 1: 0;}

long long n;

bool solve();

int main() {
    while (solve());
    return 0;
}

bool solve() {
    scanf("%lld", &n);
    if (n == 0)
        return false;
    long long cnt = n - 1;
    for (long long i = 1; ; ++i) {
        if (i * i * 2 >= n)
            break;
        long long m = n / 2 / i;
        if (m * i * 2 == n)
            --m;
        cnt += (m - i) * 2 + 1;
    //printf("-- %I64d\n", cnt);
    }
    //printf("-- %I64d\n", cnt);
    printf("%lld\n", cnt * 8 + 8 * n);
    return true;
}
accuracy: 1
time_ms: 70
memory_kb: 880
final_rank: 18

code_snippet: #include<iostream>
#include<cmath>
using namespace std;
const double eps = 1.0e-9;
int main()
{
  while(true){
    long long int n,r,ans=0;
    scanf("%lld",&n);
    if( n == 0 )break;
    long long int tmp = n>>1;
    long long int rn = (long long int)ceil(sqrt(tmp));
    for(int i = 2; i <=rn; ++i){
      int _2i1 = (i-1)<<1;
      if(n%_2i1==0)tmp+=n/_2i1;
      else tmp+=n/_2i1+1;
    }
    tmp <<= 1;
    tmp -= rn*rn;
    ans = (n+tmp)<<3;
    printf("%lld\n",ans);
  }
  return 0;
}
accuracy: 1
time_ms: 80
memory_kb: 888
final_rank: 19