Skip to main content
Commonmark migration
Source Link

#C++, 53 bytes

C++, 53 bytes

Just use the formula. n is 1-indexed and k is 0-indexed.

[](int n,int k){return k/n*(k/n+1)/2*n+k%n*(k/n+1);};

Try it online!

#C++, 53 bytes

Just use the formula. n is 1-indexed and k is 0-indexed.

[](int n,int k){return k/n*(k/n+1)/2*n+k%n*(k/n+1);};

Try it online!

C++, 53 bytes

Just use the formula. n is 1-indexed and k is 0-indexed.

[](int n,int k){return k/n*(k/n+1)/2*n+k%n*(k/n+1);};

Try it online!

deleted 202 characters in body
Source Link
Colera Su
  • 2.4k
  • 13
  • 29

#C++, 53 bytes

Just use the formula. n is 1-indexed and k is 0-indexed.

[](int n,int k){return k/n*(k/n+1)/2*n+k%n*(k/n+1);};

Try it online!


Use exactly the same approach on C will get 43 bytes, and on Python 2 38 bytes.

#C++, 53 bytes

Just use the formula. n is 1-indexed and k is 0-indexed.

[](int n,int k){return k/n*(k/n+1)/2*n+k%n*(k/n+1);};

Try it online!


Use exactly the same approach on C will get 43 bytes, and on Python 2 38 bytes.

#C++, 53 bytes

Just use the formula. n is 1-indexed and k is 0-indexed.

[](int n,int k){return k/n*(k/n+1)/2*n+k%n*(k/n+1);};

Try it online!

added 282 characters in body
Source Link
Colera Su
  • 2.4k
  • 13
  • 29

#C++, 53 bytes

Just use the formula. n is 1-indexed and k is 0-indexed.

[](int n,int k){return k/n*(k/n+1)/2*n+k%n*(k/n+1);};

Try it online!


Use exactly the same approach on C will get 43 bytes, and on Python 2 38 bytes.

#C++, 53 bytes

Just use the formula. n is 1-indexed and k is 0-indexed.

[](int n,int k){return k/n*(k/n+1)/2*n+k%n*(k/n+1);};

Try it online!

#C++, 53 bytes

Just use the formula. n is 1-indexed and k is 0-indexed.

[](int n,int k){return k/n*(k/n+1)/2*n+k%n*(k/n+1);};

Try it online!


Use exactly the same approach on C will get 43 bytes, and on Python 2 38 bytes.

added 39 characters in body
Source Link
Colera Su
  • 2.4k
  • 13
  • 29
Loading
Source Link
Colera Su
  • 2.4k
  • 13
  • 29
Loading