paste bin
Author
Language
C++
Plain text
Accesslog
Action script
Ada
Apache
Arduino
Armasm
Autohotkey
Awk
Bash
Basic
Brainfuck
C
Clojure
Cmake
C#
css
D
Delphi
Dockerfile
Erlang
Fortran
F#
Gauss
Go
Gradle
Graphql
Groovy
Haskell
Ini
Java
JavaScript
json
Julia
Kotlin
Lasso
LaTeX
Leaf
lisp
llvm
Lua
Makefile
Markdown
Mathematica
Matlab
Nginx
Objective-C
Ocaml
Oxygene
Perl
PgSQL
php
Powershell
Processing
Profile
Properties
Puppet
Purebasic
Python
Q
QML
R
Ruby
Rust
Scala
Scheme
Scilab
Shell
Smalltalk
SQL
Swift
Typescript
VB.NET
VB Script
Verilog
Vim
Wasm
x86asm
Xml
Xquery
Yaml
source code:
#include <cstdio> #include <cstring> #define MAXN 21 int bw[MAXN][MAXN][MAXN]; int w(int a, int b, int c) { if(a<=0 || b<=0 || c<=0) { return 1; } if(a>20 || b>20 || c>20) { return w(20,20,20); } if(bw[a][b][c]!=0) { return bw[a][b][c]; } else { if(a<b && b<c) { bw[a][b][c]=w(a, b, c-1) + w(a, b-1, c-1) - w(a, b-1, c); } else { bw[a][b][c]=w(a-1, b, c) + w(a-1, b-1, c) + w(a-1, b, c-1) - w(a-1, b-1, c-1); } return bw[a][b][c]; } } int main(void) { memset(bw,0,sizeof(int)*MAXN*MAXN*MAXN); int a,b,c; while (1) { scanf("%d%d%d",&a,&b,&c); if(a==-1 && b==-1 && c==-1) { break; } printf("w(%d, %d, %d) = %d\n",a,b,c,w(a,b,c)); } return 0; }
comment: