Drkcore

12 08 2008 cpp topcoder Tweet

SRM199-DIV2-500

三角形の数を数える

パズルみたいな問題。上向きと下向きに分けて数えていけばOK

class TriangleCount {
public:
  int count(int N) {
    int result = 0;
    for(int i = 1;i<=N;++i){
      for (int j = i;j<=N;j++){
    result += j-i+1;
    int down = j - i + 1 -i;
    if ((down) > 0) result += down; 
      }
    }
    return result;
  }
};

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021