630D - Hexagons - CodeForces Solution


math *1100

Please click on ads to support us..

Python Code:

import math as mt
from collections import defaultdict,deque
from bisect import bisect_left as b_l
from bisect import bisect_right as b_r
import sys

mod=10**9+7

n=int(input())
if(n==0):
    print(1)
else:
    print((((n*(n+1))//2)*6)+1)

C++ Code:

/**
 It falls to me to inform you that this one is in the bag
 **/
//========================================================================================//
// Name        : Mohamed Ahmed Galhoum
// Cf_Handle   : ShAdoW_77
// Date        : 2023
// Goal        : reach Master || GrandMaster ("one Day I will say (I did it !!)")
/// I won’t run away anymore…
/// I won’t go back on my word…
/// That is my Ninja way !
/// Microsoft next year insha-alahh (2024 || Max_In : (2025) ) -- (2026||2027) in ICPC Insha-allah this is For Remember :) xD !
//========================================================================================//
/*
 STAY ORGANIZED
 CHANGE YOUR APPROACH
 BE CONFIDENT
 */
// =======================================================================================//
/*
 صباح كل
 السماء زرقة على التحية القى
 المسافرة الحمامات بعض كل
 .كذلك صعبا ليس سهلا ليس ما بان نفسى اذكر و
 */
// =======================================================================================//
#include<bits/stdc++.h>
using namespace std;
#define Galhoum ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#define  ll long long
#define endl "\n";
using str = string;
const int MAX = 1e5 + 10;
const int mod1 = 1e9 + 7;
const ll llOO = 0x3f3f3f3f3f3f3f3f;
#define TC_Galhoum(t) while (t--)
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<char, char> pairs;
#define F first
#define S second
#define ld long double
#define maxz(x, y) x = max(x, y)
#define minz(x, y) x = min(x, y)
#define  loop(n)     for(int i=0; i<n; i++)
#define ll_loop(n)   for(ll i=0;i<n;i++)
#define each(a, x)   for (auto& a : (x))
#define sz(a) ((int) (a).size())
#define  loop1(n)     for(int i=1; i<=n; i++)
#define  loopj(n)    for(int j=0; j<n; j++)
#define  loop_(i,j)  for(int i=0,j=1;i<n,j<n;i++,j++)
#define loop_1(i, a, b) for (int i = a; i < b; i++)
#define  YES         cout << "YES"<<endl;
#define  NO          cout << "NO" << endl;
#define alls(a)  a.begin(),a.end()
#define wez(n) int (n); scanf("%d",&(n));
#define wez2(n,m) int (n),(m); scanf("%d %d",&(n),&(m));
#define wez3(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k));
#define all(v)                ((v).begin()), ((v).end());
#define Formula(start,end) (ll)(((1.0*(end-start+1)))/2*(start+end));
const double EPS = 1e-9;
char dcmp(double a, double b) {
	return fabs(a - b) < EPS ? '=' : a > b ? '>' : '<';
}
long long powers[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096,
		8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152,
		4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456,
		536870912, 1073741824, 2147483648 };
// ====================================== My Solution ==================================== //
inline int end() {
	int N;
	cin >> N;
	return N;
}
inline long long endll() {
	ll N;
	cin >> N;
	return N;
}
inline string read() {
	str st;
	cin >> st;
	return st;
}
inline double dou() {
	double N;
	cin >> N;
	return N;
}
inline char chend() {
	char c;
	cin >> c;
	return c;
}
void My_Ninja_Way(){
	ll N = endll();
	cout <<  ((3 * N)*(N+1))+1 << endl;
}
// ======================================================================================== //
int main() {
// Opportunities don't happen. You Creat Them //
//#ifndef ONLINE_JUDGE
//	freopen("Input.txt", "r", stdin);
//	freopen("Output.txt", "w", stdout);
//#endif
	Galhoum
	int t = 1;
	TC_Galhoum(t) {
		My_Ninja_Way();
	}
	cerr << "Galhoum here" << endl;
	return 0;
}
// ======================================================================================== //
/*
 * Think twice, code once
 * Think of different approaches to tackle a problem: write them down.
 * Think of different views of the problem. don't look from only one side.
 * don't get stuck in one approach.
 * common mistakes: over_flow
 *                  - out_of_bound index
 *                  -infinite loop
 *                  -corner cases
 *                  -duplication counting.
 */
// ======================================================================================== //


Comments

Submit
0 Comments
More Questions

1618A - Polycarp and Sums of Subsequences
1618B - Missing Bigram
938. Range Sum of BST
147. Insertion Sort List
310. Minimum Height Trees
2110. Number of Smooth Descent Periods of a Stock
2109. Adding Spaces to a String
2108. Find First Palindromic String in the Array
394. Decode String
902. Numbers At Most N Given Digit Set
221. Maximal Square
1200. Minimum Absolute Difference
1619B - Squares and Cubes
1619A - Square String
1629B - GCD Arrays
1629A - Download More RAM
1629C - Meximum Array
1629D - Peculiar Movie Preferences
1629E - Grid Xor
1629F1 - Game on Sum (Easy Version)
2148. Count Elements With Strictly Smaller and Greater Elements
2149. Rearrange Array Elements by Sign
2150. Find All Lonely Numbers in the Array
2151. Maximum Good People Based on Statements
2144. Minimum Cost of Buying Candies With Discount
Non empty subsets
1630A - And Matching
1630B - Range and Partition
1630C - Paint the Middle
1630D - Flipping Range