
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
C++ program to count number of dodecagons we can make of size d
Suppose we have a number d. Consider there is an infinite number of square tiles and regular triangular tiles with sides length 1. We have to find in how many ways we can form regular dodecagon (12-sided polygon) with sides d using these tiles. If the answer is too large, return result mod 998244353.
Steps
To solve this, we will follow these steps−
b := floor of d/2 - 1 c := 1 for initialize i := 2, when i < d, update (increase i by 1), do: b := b * (floor of d/2) c := c * i return (b / c)
Example
Let us see the following implementation to get better understanding −
#include <bits/stdc++.h> using namespace std; int solve(int d){ int b = ((d << 1) - 1); int c = 1; for (int i = 2; i < d; i++){ b *= (d << 1) - i; c *= i; } return (b / c); } int main(){ int d = 1; cout << solve(d) << endl; }
Input
1
Output
1
- Related Articles
- Program to count number of strings we can make using grammar rules in Python
- Program to count number of unique palindromes we can make using string characters in Python
- Program to count number of ways we can make a list of values by splitting numeric string in Python
- C++ program to count number of cities we can visit from each city with given operations
- C++ program to count minimum number of operations needed to make number n to 1
- Program to count number of ways we can throw n dices in Python
- Program to count number of ways we can place nonoverlapping edges to connect all nodes in C++
- Program to find maximum number of people we can make happy in Python
- Program to count number of ways we can distribute coins to workers in Python
- Program to count number of words we can generate from matrix of letters in Python
- Program to find number of ways we can concatenate words to make palindromes in Python
- Program to find possible number of palindromes we can make by trimming string in Python
- Program to count number of palindromes of size k can be formed from the given string characters in Python
- C++ code to count number of notebooks to make n origamis
- C++ Program to count number of teams can be formed for coding challenge

Advertisements